Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same user with multiple devices kicks out existing device #28

Open
rotx opened this issue Apr 30, 2023 · 4 comments
Open

Same user with multiple devices kicks out existing device #28

rotx opened this issue Apr 30, 2023 · 4 comments

Comments

@rotx
Copy link

rotx commented Apr 30, 2023

I have several iOS devices. An old iPhone, a new iPhone (which started out life as a clone of the old one), and an iPad.
When I start mail, they all register. However, the old iPhone and new iPhone have the same AccountID, but different DeviceTokens. It looks like the code currently only supports one DeviceToken per AccountId. Whichever registers last wins.
Looks like the Account data structure and the Registration functions in database.go would have to be modified to support this?

@freswa
Copy link
Owner

freswa commented Apr 30, 2023

The code supports multiple devices just fine.

@rotx
Copy link
Author

rotx commented Apr 30, 2023

I should probably add a little more detail. It supports multiple devices, but not when they only differ by device token. Here's an example:

/var/lib/xaps/database.json with New_iPhone + iPad registered and working:

{
  "Users": {
    "rotx": {
      "Accounts": {
        "DB222D09-0BB8-4EE5-948C-9A1D7DCBA6CD": {
          "DeviceToken": "5F8FEF99835B45EDB9FA860DFCC209822FA7A7AC684E4977A811573E9C9B3A74",
          "Mailboxes": [
            "INBOX",
            "Open Orders",
            "Sent Messages"
          ],
          "RegistrationTime": "2023-04-29T14:36:40.413465243-05:00"
        },
        "A51D9BE1-2050-4279-98CF-A01D9DEE1D62": {
          "DeviceToken": "C2D1B61851234DFB90C93A192BFF9F773A927AA595DF4850880EE21EE46C1F74",
          "Mailboxes": [
            "INBOX",
            "Open Orders",
            "Sent Messages"
          ],
          "RegistrationTime": "2023-04-29T23:42:15.963719766-05:00"
        }
      }
    }
  },
  "AppleCerts": {
    "Signature": [
...

Starting the Old_iPhone:

Apr 30 10:47:56 mail dovecot[4931]: imap(rotx)<276831><rbKKoY/700MKMgo3>: Debug: Sending registration: {"ApsAccountId":"DB222D09-0BB8-4EE5-948C-9A1D7DCBA6CD","ApsDeviceToken":"B6B01ED75F0D4AED8246AADB79F9556BB540897D939E4E2D969B6EB1E99C48EF","ApsSubtopic":"com.apple.mobilemail","Username":"rotx","Mailboxes": ["Open Orders","INBOX","Sent Messages"]}
Apr 30 10:47:58 mail dovecot[4931]: imap(rotx)<276831><rbKKoY/700MKMgo3>: Debug: Notification sent successfully: 200 OK

/var/lib/xaps/database.json now (new iPhone is gone, old iPhone has replaced it because it has the same "Account" even though it has a different DeviceToken:

{
  "Users": {
    "rotx": {
      "Accounts": {
        "DB222D09-0BB8-4EE5-948C-9A1D7DCBA6CD": {
          "DeviceToken": "B6B01ED75F0D4AED8246AADB79F9556BB540897D939E4E2D969B6EB1E99C48EF",
          "Mailboxes": [
            "Open Orders",
            "INBOX",
            "Sent Messages"
          ],
          "RegistrationTime": "2023-04-30T10:47:57.400423029-05:00"
        },
        "A51D9BE1-2050-4279-98CF-A01D9DEE1D62": {
          "DeviceToken": "C2D1B61851234DFB90C93A192BFF9F773A927AA595DF4850880EE21EE46C1F74",
          "Mailboxes": [
            "INBOX",
            "Open Orders",
            "Sent Messages"
          ],
          "RegistrationTime": "2023-04-29T23:42:15.963719766-05:00"
        }
      }
    }
  },
  "AppleCerts": {
    "Signature": [
...

Note how the DB222D09-0BB8-4EE5-948C-9A1D7DCBA6CD account entry in the database has dropped the DeviceToken for New_iPhone and is now listing Old_iPhone.

@freswa
Copy link
Owner

freswa commented Apr 30, 2023

You could work around this by deleting the mail account on one device and recreate it. I see that this is a use-case, but it's a very narrow one. It would require database migration and a partial rewrite. If there is someone willing to sponsor the work or create a PR, give me a ping :)

@rotx
Copy link
Author

rotx commented Apr 30, 2023

Agreed. Either way there's some risk in modifying the database structure, so perhaps it can simply be documented. I added this and a few other things to #29

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

No branches or pull requests

2 participants