diff options
Diffstat (limited to 'transferengine-plugins/mastodonshareservicestatus.cpp')
| -rw-r--r-- | transferengine-plugins/mastodonshareservicestatus.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/transferengine-plugins/mastodonshareservicestatus.cpp b/transferengine-plugins/mastodonshareservicestatus.cpp index f3c96ca..2591520 100644 --- a/transferengine-plugins/mastodonshareservicestatus.cpp +++ b/transferengine-plugins/mastodonshareservicestatus.cpp @@ -1,5 +1,7 @@ /* - * Copyright (C) 2013-2026 Jolla Ltd. + * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause */ #include "mastodonshareservicestatus.h" @@ -27,6 +29,11 @@ MastodonShareServiceStatus::MastodonShareServiceStatus(QObject *parent) { } +QString MastodonShareServiceStatus::authServiceName() const +{ + return QStringLiteral("mastodon-microblog"); +} + void MastodonShareServiceStatus::signIn(int accountId) { Accounts::Account *account = Accounts::Account::fromId(m_accountManager, accountId, this); @@ -36,9 +43,9 @@ void MastodonShareServiceStatus::signIn(int accountId) return; } - const Accounts::Service service(m_accountManager->service(m_serviceName)); + const Accounts::Service service(m_accountManager->service(authServiceName())); if (!service.isValid()) { - qWarning() << Q_FUNC_INFO << "Invalid auth service" << m_serviceName; + qWarning() << Q_FUNC_INFO << "Invalid auth service" << authServiceName(); account->deleteLater(); setAccountDetailsState(accountId, Error); return; @@ -123,7 +130,7 @@ void MastodonShareServiceStatus::signOnError(const SignOn::Error &error) << error.type() << error.message(); if (accountId > 0 && error.type() == SignOn::Error::UserInteraction) { - setCredentialsNeedUpdate(accountId, m_serviceName); + setCredentialsNeedUpdate(accountId, authServiceName()); } session->disconnect(this); @@ -186,7 +193,7 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode) bool signInActive = false; Q_FOREACH (Accounts::AccountId id, m_accountManager->accountList()) { - Accounts::Account *acc = m_accountManager->account(id); + Accounts::Account *acc = Accounts::Account::fromId(m_accountManager, id, this); if (!acc) { qWarning() << Q_FUNC_INFO << "Failed to get account for id:" << id; @@ -206,6 +213,7 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode) } if (!service.isValid() || !serviceFound) { + acc->deleteLater(); continue; } @@ -214,19 +222,23 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode) const bool shareServiceEnabled = acc->enabled(); if (!accountEnabled || !shareServiceEnabled) { acc->selectService(Accounts::Service()); + acc->deleteLater(); continue; } if (acc->value(QStringLiteral("CredentialsNeedUpdate")).toBool()) { qWarning() << Q_FUNC_INFO << "Credentials need update for account id:" << id; acc->selectService(Accounts::Service()); + acc->deleteLater(); continue; } if (!m_accountIdToDetailsIdx.contains(id)) { AccountDetails details; details.accountId = id; + acc->selectService(Accounts::Service()); details.apiHost = MastodonAuthUtils::normalizeApiHost(acc->value(QStringLiteral("api/Host")).toString()); + acc->selectService(service); QUrl apiUrl(details.apiHost); details.providerName = apiUrl.host(); @@ -256,6 +268,7 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode) } acc->selectService(Accounts::Service()); + acc->deleteLater(); } if (!signInActive) { |
