summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@jolla.com>2026-03-22 11:21:35 +0100
committerAndrew Branson <andrew.branson@jolla.com>2026-03-22 19:31:10 +0100
commit86bc18b99cc539949934e22f92f430f040117b21 (patch)
tree260be9618fa4c6685a1f69ad4cd531511704182c
parentd68706916727ccade2f6ceb7ea3faca32d6e3b64 (diff)
Single auth service, and msyncd restart
- Use the microblog service for all auth - Restart msyncd on install if it's running
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.cpp10
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.h1
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.cpp5
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.h1
-rw-r--r--rpm/sailfish-account-mastodon.spec1
-rw-r--r--settings/accounts/ui/MastodonSettingsDisplay.qml5
-rw-r--r--transferengine-plugins/mastodonshareservicestatus.cpp13
-rw-r--r--transferengine-plugins/mastodonshareservicestatus.h1
8 files changed, 32 insertions, 5 deletions
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.cpp b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.cpp
index 14b3511..ddf6686 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.cpp
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.cpp
@@ -81,6 +81,11 @@ QString MastodonNotificationsDataTypeSyncAdaptor::apiHost(int accountId) const
return m_apiHosts.value(accountId, QStringLiteral("https://mastodon.social"));
}
+QString MastodonNotificationsDataTypeSyncAdaptor::authServiceName() const
+{
+ return syncServiceName();
+}
+
void MastodonNotificationsDataTypeSyncAdaptor::errorHandler(QNetworkReply::NetworkError err)
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
@@ -125,7 +130,7 @@ void MastodonNotificationsDataTypeSyncAdaptor::sslErrorsHandler(const QList<QSsl
void MastodonNotificationsDataTypeSyncAdaptor::setCredentialsNeedUpdate(Accounts::Account *account)
{
qCInfo(lcMastodonNotificationsSync) << "sociald:Mastodon: setting CredentialsNeedUpdate to true for account:" << account->id();
- Accounts::Service srv(m_accountManager->service(syncServiceName()));
+ Accounts::Service srv(m_accountManager->service(authServiceName()));
account->selectService(srv);
account->setValue(QStringLiteral("CredentialsNeedUpdate"), QVariant::fromValue<bool>(true));
account->setValue(QStringLiteral("CredentialsNeedUpdateFrom"), QVariant::fromValue<QString>(QString::fromLatin1("sociald-mastodon")));
@@ -141,8 +146,9 @@ void MastodonNotificationsDataTypeSyncAdaptor::signIn(Accounts::Account *account
return;
}
- Accounts::Service srv(m_accountManager->service(syncServiceName()));
+ Accounts::Service srv(m_accountManager->service(authServiceName()));
account->selectService(srv);
+
SignOn::Identity *identity = account->credentialsId() > 0
? SignOn::Identity::existingIdentity(account->credentialsId())
: 0;
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.h b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.h
index 3bb6e23..3c61ade 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.h
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodondatatypesyncadaptor.h
@@ -48,6 +48,7 @@ public:
protected:
QString apiHost(int accountId) const;
virtual void updateDataForAccount(int accountId);
+ virtual QString authServiceName() const;
virtual void beginSync(int accountId, const QString &accessToken) = 0;
protected Q_SLOTS:
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.cpp b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.cpp
index 8a2c610..8d21782 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.cpp
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.cpp
@@ -303,6 +303,11 @@ QString MastodonNotificationsSyncAdaptor::syncServiceName() const
return QStringLiteral("mastodon-notifications");
}
+QString MastodonNotificationsSyncAdaptor::authServiceName() const
+{
+ return QStringLiteral("mastodon-microblog");
+}
+
void MastodonNotificationsSyncAdaptor::purgeDataForOldAccount(int oldId, SocialNetworkSyncAdaptor::PurgeMode)
{
closeAccountNotifications(oldId);
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.h b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.h
index 9711549..4c667fa 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.h
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-notifications/mastodonnotificationssyncadaptor.h
@@ -41,6 +41,7 @@ public:
QString syncServiceName() const override;
protected:
+ QString authServiceName() const override;
void purgeDataForOldAccount(int oldId, SocialNetworkSyncAdaptor::PurgeMode mode) override;
void beginSync(int accountId, const QString &accessToken) override;
void finalize(int accountId) override;
diff --git a/rpm/sailfish-account-mastodon.spec b/rpm/sailfish-account-mastodon.spec
index 6391e9f..64dd979 100644
--- a/rpm/sailfish-account-mastodon.spec
+++ b/rpm/sailfish-account-mastodon.spec
@@ -59,6 +59,7 @@ Translation source files for sailfish-account-mastodon components.
%post
/sbin/ldconfig
%{_libexecdir}/manage-groups add account-mastodon || :
+systemctl-user try-restart msyncd.service || :
%postun
/sbin/ldconfig
diff --git a/settings/accounts/ui/MastodonSettingsDisplay.qml b/settings/accounts/ui/MastodonSettingsDisplay.qml
index fe8ba04..35d657b 100644
--- a/settings/accounts/ui/MastodonSettingsDisplay.qml
+++ b/settings/accounts/ui/MastodonSettingsDisplay.qml
@@ -13,6 +13,7 @@ StandardAccountSettingsDisplay {
id: root
settingsModified: true
+ property bool postsServiceEnabled: false
function refreshDescriptionEditor() {
var description = root.account.configurationValues("")["description"]
@@ -124,6 +125,9 @@ StandardAccountSettingsDisplay {
: "")
visible: text.length > 0
onCheckedChanged: {
+ if (model.serviceName === "mastodon-microblog") {
+ root.postsServiceEnabled = checked
+ }
if (checked) {
root.account.enableWithService(model.serviceName)
} else {
@@ -140,6 +144,7 @@ StandardAccountSettingsDisplay {
text: qsTrId("settings-accounts-mastodon-la-auto_sync_feed")
//% "Fetch new posts periodically when browsing Events Mastodon feed."
description: qsTrId("settings-accounts-mastodon-la-auto_sync_feed_description")
+ enabled: root.postsServiceEnabled
onCheckedChanged: {
autoSyncConf.value = checked
diff --git a/transferengine-plugins/mastodonshareservicestatus.cpp b/transferengine-plugins/mastodonshareservicestatus.cpp
index 3ac05d5..c48be67 100644
--- a/transferengine-plugins/mastodonshareservicestatus.cpp
+++ b/transferengine-plugins/mastodonshareservicestatus.cpp
@@ -27,6 +27,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 +41,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 +128,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);
@@ -229,7 +234,9 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode)
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();
diff --git a/transferengine-plugins/mastodonshareservicestatus.h b/transferengine-plugins/mastodonshareservicestatus.h
index cf2e1f8..42fe171 100644
--- a/transferengine-plugins/mastodonshareservicestatus.h
+++ b/transferengine-plugins/mastodonshareservicestatus.h
@@ -64,6 +64,7 @@ private:
Error
};
+ QString authServiceName() const;
void setAccountDetailsState(int accountId, AccountDetailsState state);
void signIn(int accountId);