localAccountUtils.associate_servers() is horrible
Categories
(MailNews Core :: Testing Infrastructure, enhancement)
Tracking
(Not tracked)
People
(Reporter: jorgk-bmo, Assigned: aceman)
Details
Attachments
(1 file)
(deleted),
patch
|
jorgk-bmo
:
review+
|
Details | Diff | Splinter Review |
Check this:
associate_servers: function(aIncoming, aOutgoingServer, aSetAsDefault) {
let identity = MailServices.accounts.createIdentity();
identity.smtpServerKey = aOutgoingServer.key;
if (aIncoming instanceof Ci.nsIMsgIncomingServer)
aIncoming = MailServices.accounts.FindAccountForServer(aIncoming);
aIncoming.addIdentity(identity);
if (aSetAsDefault)
aIncoming.defaultIdentity = identity;
}
Hmm, we reuse/abuse the input parameter aIncoming
and I have no idea what would happen if the instanceof returned false. Then we'd try to add an identity to a server :-(
If you don't read this thoroughly, you'd think that aIncoming.defaultIdentity
is set by the funtion, but it's not. I wasted some time debugging that :-(
Aceman, can you please fix this.
(In reply to Jorg K (GMT+1) from comment #0)
Hmm, we reuse/abuse the input parameter
aIncoming
and
I think we do that sometimes.
I have no idea what would happen if the instanceof returned false. Then we'd try to add an identity to a server :-(
No, if it isn't a server we assume it is an account and we can add identity to that.
If you don't read this thoroughly, you'd think that
aIncoming.defaultIdentity
is set by the funtion, but it's not. I wasted some time debugging that :-(
Hm, why not?
Reporter | ||
Comment 2•6 years ago
|
||
Well, the documentation says:
* @param aIncoming The incoming server (nsIMsgIncomingServer) or account
* (nsIMsgAccount) to associate.
In case you pass in a server, the aIncoming.defaultIdentity
is set in the account, but the caller doesn't see that. I had to do this to make it work for me:
https://hg.mozilla.org/try-comm-central/rev/353a7d02af0986b8b985555d3cd92af56963a37e#l4.43
+ // We also need to have a working identity, including an email address.
+ localAccountUtils.associate_servers(incoming, server, true);
+ let account = MailServices.accounts.FindAccountForServer(incoming);
+ let identity = account.defaultIdentity;
+ dump(identity.toString());
+ identity.email = "tinderbox@tinderbox.invalid";
+ MailServices.accounts.defaultAccount = account;
(In reply to Jorg K (GMT+1) from comment #2)
Well, the documentation says:
* @param aIncoming The incoming server (nsIMsgIncomingServer) or account * (nsIMsgAccount) to associate.
In case you pass in a server, the
aIncoming.defaultIdentity
is set in the account, but the caller doesn't see that.
Doesn't see it on the passed server, but it does happen where it should happen :)
I had to do this to make it work for me:
What does 'work' mean. It seems to me it works.
- // We also need to have a working identity, including an email address.
- localAccountUtils.associate_servers(incoming, server, true);
- let account = MailServices.accounts.FindAccountForServer(incoming);
- let identity = account.defaultIdentity;
- dump(identity.toString());
- identity.email = "tinderbox@tinderbox.invalid";
This is also what https://searchfox.org/comm-central/source/mail/components/test/unit/test_about_support.js#100 does, and in the account the default identity is set.
So if you'd like to change it to take an account directly, we can do that, there are only these 2 callers.
- MailServices.accounts.defaultAccount = account;
I assume this is not related to the discussed issue.
Reporter | ||
Comment 4•6 years ago
|
||
OK, forget it. Sorry about the noise.
We can still do some cleanup in the area.
Reporter | ||
Comment 7•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/a7097aec4a71
make associate_servers() take an incoming account instead of a server. r=jorgk
Reporter | ||
Updated•6 years ago
|
Description
•