Open qyb opened 2 years ago
I suggest that we add a getPersonalAccountId() method, and keep getFirstAccountId until 2.0 release.
But isn't there the same problem with personal accounts? I am not sure I understood the specs correctly, but there might be multiple personal accounts and multiple primary accounts? @chibenwa
Actually:
Each capability have it's primary ccount
This is usefull for implementing a Proxy, where capabilities are implemented by different servers.
I would expect primary accounts to be personnal, but that is already an assumption.
I suggest that we add a getPersonalAccountId() method,
IMO we can easily improve things by having: getPrimaryAccountId(Capability)
which would mirror directly the session primaryAccounts
field. IMO knowing if this is personal or not is secondary.
and keep getFirstAccountId until 2.0 release.
Is there a way to mark things as deprecated in typescript ?
Actually: IMO we can easily improve things by having:
getPrimaryAccountId(Capability)
which would mirror directly the sessionprimaryAccounts
field. IMO knowing if this is personal or not is secondary.
maybe something like (untested):
public getPrimaryAccountId(capability: string = 'urn:ietf:params:jmap:mail'): string {
const primaryAccounts = this.session?.primaryAccounts;
if (primaryAccounts && capability in primaryAccounts) {
return primaryAccounts[capability];
}
throw new Error('No account available for this session');
}
is it right?
Maybe refining a bit the error message but yes ;-)
'No primary account available for $capability in this session'
would make more sense.
Also coming from the Java world I would likely encode the 'missing' concept in the return type instead of hard coding failure, which would then allow the caller to decide what to do. Optional<String>
in java. string?
in typescript maybe? (I'm a typescript noob....)
Also coming from the Java world I would likely encode the 'missing' concept in the return type instead of hard coding failure, which would then allow the caller to decide what to do.
Optional<String>
in java.string?
in typescript maybe? (I'm a typescript noob....)
Because we will use it in replaceAccountId
😅 ,
private replaceAccountId<U extends IReplaceableAccountId>(input: U): U {
return input.accountId !== null
? input
: {
...input,
accountId: this.getFirstAccountId(),
};
}
Because we will use it in
replaceAccountId
😅 ,private replaceAccountId<U extends IReplaceableAccountId>(input: U): U { return input.accountId !== null ? input : { ...input, accountId: this.getFirstAccountId(), }; }
I found that emailSubmission_get/emailSubmission_changes/emailSubmission_set should depends getPrimaryAccountId('urn:ietf:params:jmap:submission') ...
ðŸ˜
The spec does not guarantee the personal(primary mail) account is the first element of session.accounts. I'm not sure whether JamesServer supports account/mailbox sharing. But cyrus-imapd seems that the personal account always is the last element of session.accounts.
I suggest that we add a getPersonalAccountId() method, and keep getFirstAccountId until 2.0 release.