Commit a2a31d38 authored by Michael Gratton's avatar Michael Gratton 🤞 Committed by Michael Gratton

Fix an error being thrown when an active GOA account is disabled

When GOA accounts are disabled in Settings, they are updated in Geary.
This caused an error updating credentials since we were trying to
update the credentials for a now-disabled account.

This patch makes Geary not do this.
parent 7dc07bda
Pipeline #65703 passed with stages
in 16 minutes and 29 seconds
......@@ -784,11 +784,10 @@ public class Accounts.Manager : GLib.Object {
}
private bool is_valid_goa_account(Goa.Object handle) {
// Goa.Account.mail_disabled doesn't seem to reflect if we get
// get a valid mail object here, so just rely on that instead.
Goa.Mail? mail = handle.get_mail();
return (
mail != null &&
!handle.get_account().mail_disabled &&
!Geary.String.is_empty(mail.imap_host) &&
!Geary.String.is_empty(mail.smtp_host)
);
......@@ -838,15 +837,18 @@ public class Accounts.Manager : GLib.Object {
}
private async void update_goa_account(Geary.AccountInformation account,
bool is_available,
GLib.Cancellable? cancellable) {
GoaMediator mediator = (GoaMediator) account.mediator;
try {
yield mediator.update(account, cancellable);
// Update will clear the creds, so make sure they get
// refreshed
yield account.load_outgoing_credentials(cancellable);
yield account.load_incoming_credentials(cancellable);
if (is_available) {
// Update will clear the creds, so make sure they get
// refreshed
yield account.load_outgoing_credentials(cancellable);
yield account.load_incoming_credentials(cancellable);
}
} catch (GLib.Error err) {
report_problem(
new Geary.AccountProblemReport(
......@@ -858,7 +860,7 @@ public class Accounts.Manager : GLib.Object {
// XXX need to notify the engine that creds may have changed
set_available(account, mediator.is_available);
set_available(account, is_available);
}
......@@ -929,7 +931,11 @@ public class Accounts.Manager : GLib.Object {
// We already know about this account, so check that it is
// still valid. If not, the account should be disabled,
// not deleted, since it may be re-enabled at some point.
this.update_goa_account.begin(state.account, null);
this.update_goa_account.begin(
state.account,
is_valid_goa_account(account),
null
);
} else {
// We haven't created an account for this GOA account
// before, so try doing so now.
......
......@@ -10,15 +10,6 @@
public class GoaMediator : Geary.CredentialsMediator, Object {
public bool is_available {
get {
// Goa.Account.mail_disabled doesn't seem to reflect if we
// get can get a valid mail object or not, so just rely on
// actually getting one instead.
return this.handle.get_mail() != null;
}
}
private Goa.Object handle;
......@@ -111,7 +102,7 @@ public class GoaMediator : Geary.CredentialsMediator, Object {
// password" or "GOA credentials need renewing" or
// something. Connect to the GOA service and wait until we
// hear that needs attention is no longer true.
return this.is_available;
return false;
}
private Geary.Credentials.Method get_auth_method() throws GLib.Error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment