Support binding 3PIDs

Closes network/neochat#565
This commit is contained in:
James Graham
2024-05-31 09:25:42 +00:00
parent ab4af48e52
commit 227ebd610a
11 changed files with 521 additions and 69 deletions

View File

@@ -60,6 +60,9 @@ void NeoChatConnection::connectSignals()
if (type == QLatin1String("org.kde.neochat.account_label")) {
Q_EMIT labelChanged();
}
if (type == QLatin1String("m.identity_server")) {
Q_EMIT identityServerChanged();
}
});
connect(this, &NeoChatConnection::syncDone, this, [this] {
setIsOnline(true);
@@ -256,6 +259,41 @@ ThreePIdModel *NeoChatConnection::threePIdModel() const
return m_threePIdModel;
}
bool NeoChatConnection::hasIdentityServer() const
{
if (!hasAccountData(QLatin1String("m.identity_server"))) {
return false;
}
const auto url = accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return true;
}
return false;
}
QUrl NeoChatConnection::identityServer() const
{
if (!hasAccountData(QLatin1String("m.identity_server"))) {
return {};
}
const auto url = accountData(QLatin1String("m.identity_server"))->contentPart<QUrl>(QLatin1String("base_url"));
if (!url.isEmpty()) {
return url;
}
return {};
}
QString NeoChatConnection::identityServerUIString() const
{
if (!hasIdentityServer()) {
return i18nc("@info", "No identity server configured");
}
return identityServer().toString();
}
void NeoChatConnection::createRoom(const QString &name, const QString &topic, const QString &parent, bool setChildParent)
{
QList<CreateRoomJob::StateEvent> initialStateEvents;