Skip to content

Conversation

@missytake
Copy link
Contributor

fix #24

@missytake
Copy link
Contributor Author

/new_message still has a weird jsonRPC error which is hard to track down. After I ran it once, it runs in an error on every startup:

ERROR:root:Exception in the writer loop
Traceback (most recent call last):
  File "/home/user/code/pyinfra-sysadmin/lib/team_bot/.venv/lib/python3.12/site-packages/deltachat_rpc_client/rpc.py", line 140, in writer_loop
    data = (json.dumps(request) + "\n").encode()
            ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Contact is not JSON serializable

@missytake
Copy link
Contributor Author

/new_message still has a weird jsonRPC error which is hard to track down. After I ran it once, it runs in an error on every startup:

ERROR:root:Exception in the writer loop
Traceback (most recent call last):
  File "/home/user/code/pyinfra-sysadmin/lib/team_bot/.venv/lib/python3.12/site-packages/deltachat_rpc_client/rpc.py", line 140, in writer_loop
    data = (json.dumps(request) + "\n").encode()
            ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Contact is not JSON serializable

fixed. just passing the message ID for the quote makes more sense. hard to debug though.

@missytake
Copy link
Contributor Author

still needed:

  • pyinfra deployment, including testing the migration
  • fix CI
  • good opportunity to write tests. we can look at group-editor-bot for inspiration.

@missytake
Copy link
Contributor Author

Right now we get an ERROR deltachat_rpc_server: Error: "/home/b_odylab/.config/team_bot/[email protected]/accounts.toml" does not exist. - seems we can't just start from a sqlite file anymore.

This made me realize, that you do not even have to specify accounts_dir with deltachat-rpc-client. We could just use whatever default directory we get; the --dbdir flag could be used for "migrate from old delta.sqlite + pickle.db format instead.

@missytake
Copy link
Contributor Author

missytake commented Jan 7, 2026

This made me realize, that you do not even have to specify accounts_dir with deltachat-rpc-client. We could just use whatever default directory we get; the --dbdir flag could be used for "migrate from old delta.sqlite + pickle.db format instead.

This makes less sense I'm afraid - the default directory is just accounts/ in the current working directory, which will contain an accounts.toml, and a directory with some uuid as a name, which contains the database. The UUID can't be accessed through the RPC bindings, so that we're blind about where our data actually is, slightly annoying.

What we can do in a migration:

  1. let with Rpc(**kwargs) as rpc: create the accounts.toml
  2. let deltachat.add_account() create the new directory
  3. then simply move the old delta.sqlite (including blob files) to the new directory (just use any directory in the accounts_dir, there should be only one)
  4. create a new rpc object and get a new account object from the directory, to run deltachat's DB migrations
  5. import the data from pickle.db
  6. delete pickle.db

@missytake
Copy link
Contributor Author

missytake commented Jan 7, 2026

Bugs found:

  • We don't want to forward messages to the outside chat, but send them completely anew
  • /new_message: sending out unencrypted emails doesn't work: ERROR:root:Couldn't find valid contact for [email protected]

@missytake missytake changed the title WIP: migrate to RPC bindings migrate to RPC bindings Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use RPC bindings

2 participants