From fb7303efa0653b06062f8f9983a191019e682af3 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 25 Jul 2024 15:04:43 -0400 Subject: [PATCH] Revert "Allow blocking invites from people you don't share a room with" This reverts commit ef5585d312485bce786e7c92124db6d87934bb68. This was supposed to be in an MR. --- src/CMakeLists.txt | 2 -- src/jobs/neochatgetcommonroomsjob.cpp | 14 ---------- src/jobs/neochatgetcommonroomsjob.h | 14 ---------- src/neochatconfig.kcfg | 6 ----- src/neochatconnection.cpp | 20 --------------- src/neochatconnection.h | 9 ------- src/neochatroom.cpp | 37 +++++---------------------- src/settings/NeoChatSecurityPage.qml | 37 ++++++++------------------- 8 files changed, 17 insertions(+), 122 deletions(-) delete mode 100644 src/jobs/neochatgetcommonroomsjob.cpp delete mode 100644 src/jobs/neochatgetcommonroomsjob.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9d8edaa0..aa89f0ca1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,8 +134,6 @@ add_library(neochat STATIC jobs/neochatdeletedevicejob.h jobs/neochatchangepasswordjob.cpp jobs/neochatchangepasswordjob.h - jobs/neochatgetcommonroomsjob.cpp - jobs/neochatgetcommonroomsjob.h mediasizehelper.cpp mediasizehelper.h eventhandler.cpp diff --git a/src/jobs/neochatgetcommonroomsjob.cpp b/src/jobs/neochatgetcommonroomsjob.cpp deleted file mode 100644 index 8a57a58a0..000000000 --- a/src/jobs/neochatgetcommonroomsjob.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Joshua Goins -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "neochatgetcommonroomsjob.h" - -using namespace Quotient; - -NeochatGetCommonRoomsJob::NeochatGetCommonRoomsJob(const QString &userId, const Omittable &auth) - : BaseJob(HttpVerb::Get, - QStringLiteral("GetCommonRoomsJob"), - QStringLiteral("/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms").toLatin1(), - QUrlQuery({{QStringLiteral("user_id"), userId}})) -{ -} diff --git a/src/jobs/neochatgetcommonroomsjob.h b/src/jobs/neochatgetcommonroomsjob.h deleted file mode 100644 index 3d3dde927..000000000 --- a/src/jobs/neochatgetcommonroomsjob.h +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Joshua Goins -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include - -// TODO: Upstream to libQuotient -class NeochatGetCommonRoomsJob : public Quotient::BaseJob -{ -public: - explicit NeochatGetCommonRoomsJob(const QString &userId, const Quotient::Omittable &auth = {}); -}; diff --git a/src/neochatconfig.kcfg b/src/neochatconfig.kcfg index 3b0cb044b..4dff7510b 100644 --- a/src/neochatconfig.kcfg +++ b/src/neochatconfig.kcfg @@ -187,11 +187,5 @@ false - - - - true - - diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index f859f87f8..89fbcd61a 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -133,20 +132,6 @@ void NeoChatConnection::connectSignals() Q_EMIT homeNotificationsChanged(); Q_EMIT homeHaveHighlightNotificationsChanged(); }); - - // Fetch unstable features - // TODO: Expose unstableFeatures() in libQuotient - connect( - this, - &Connection::connected, - this, - [this] { - callApi(BackgroundRequest).then([this](const GetVersionsJob::Response &r) { - m_canCheckMutualRooms = r.unstableFeatures.contains("uk.half-shot.msc2666.query_mutual_rooms"_ls); - Q_EMIT canCheckMutualRoomsChanged(); - }); - }, - Qt::SingleShotConnection); } int NeoChatConnection::badgeNotificationCount() const @@ -215,11 +200,6 @@ QVariantList NeoChatConnection::getSupportedRoomVersions() const return supportedRoomVersions; } -bool NeoChatConnection::canCheckMutualRooms() const -{ - return m_canCheckMutualRooms; -} - void NeoChatConnection::changePassword(const QString ¤tPassword, const QString &newPassword) { auto job = callApi(newPassword, false); diff --git a/src/neochatconnection.h b/src/neochatconnection.h index 81c4a2f31..4c57766ee 100644 --- a/src/neochatconnection.h +++ b/src/neochatconnection.h @@ -79,11 +79,6 @@ class NeoChatConnection : public Quotient::Connection */ Q_PROPERTY(bool isOnline READ isOnline WRITE setIsOnline NOTIFY isOnlineChanged) - /** - * @brief Whether the server supports querying a user's mutual rooms. - */ - Q_PROPERTY(bool canCheckMutualRooms READ canCheckMutualRooms NOTIFY canCheckMutualRoomsChanged) - public: /** * @brief Defines the status after an attempt to change the password on an account. @@ -100,7 +95,6 @@ public: Q_INVOKABLE void logout(bool serverSideLogout); Q_INVOKABLE QVariantList getSupportedRoomVersions() const; - bool canCheckMutualRooms() const; /** * @brief Change the password for an account. @@ -202,7 +196,6 @@ Q_SIGNALS: void passwordStatus(NeoChatConnection::PasswordStatus status); void userConsentRequired(QUrl url); void badgeNotificationCountChanged(NeoChatConnection *connection, int count); - void canCheckMutualRoomsChanged(); private: bool m_isOnline = true; @@ -215,6 +208,4 @@ private: int m_badgeNotificationCount = 0; QHash m_linkPreviewers; - - bool m_canCheckMutualRooms = false; }; diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index e2b57dbb2..0d54e0dc4 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -41,7 +41,6 @@ #include "events/joinrulesevent.h" #include "events/pollevent.h" #include "filetransferpseudojob.h" -#include "jobs/neochatgetcommonroomsjob.h" #include "neochatconfig.h" #include "notificationsmanager.h" #include "roomlastmessageprovider.h" @@ -130,38 +129,14 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS return; } auto roomMemberEvent = currentState().get(localMember().id()); - - auto showNotification = [this, roomMemberEvent] { - QImage avatar_image; - if (roomMemberEvent && !member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) { - avatar_image = memberAvatar(roomMemberEvent->senderId()).get(this->connection(), 128, [] {}); - } else { - qWarning() << "using this room's avatar"; - avatar_image = avatar(128); - } - - NotificationsManager::instance().postInviteNotification(this, - displayName(), - member(roomMemberEvent->senderId()).htmlSafeDisplayName(), - avatar_image); - }; - - if (NeoChatConfig::allowUnknownInvites()) { - showNotification(); + QImage avatar_image; + if (roomMemberEvent && !member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) { + avatar_image = memberAvatar(roomMemberEvent->senderId()).get(this->connection(), 128, [] {}); } else { - auto job = this->connection()->callApi(roomMemberEvent->senderId()); - connect(job, &BaseJob::result, this, [this, job, roomMemberEvent, showNotification] { - QJsonObject replyData = job->jsonData(); - if (replyData.contains(QStringLiteral("joined"))) { - const bool inAnyOfOurRooms = !replyData[QStringLiteral("joined")].toArray().isEmpty(); - if (inAnyOfOurRooms) { - showNotification(); - } else { - leaveRoom(); - } - } - }); + qWarning() << "using this room's avatar"; + avatar_image = avatar(128); } + NotificationsManager::instance().postInviteNotification(this, displayName(), member(roomMemberEvent->senderId()).htmlSafeDisplayName(), avatar_image); }, Qt::SingleShotConnection); connect(this, &Room::changed, this, [this] { diff --git a/src/settings/NeoChatSecurityPage.qml b/src/settings/NeoChatSecurityPage.qml index 5af6bb43a..e71975b4d 100644 --- a/src/settings/NeoChatSecurityPage.qml +++ b/src/settings/NeoChatSecurityPage.qml @@ -16,32 +16,6 @@ FormCard.FormCardPage { title: i18nc("@title", "Security") - FormCard.FormHeader { - title: i18nc("@title:group", "Invites") - } - FormCard.FormCard { - FormCard.FormCheckDelegate { - text: i18nc("@option:check", "Allow invites from anyone") - description: connection.canCheckMutualRooms ? i18n("If enabled, NeoChat shows room invites from anyone - even if you aren't in a room with them.") : i18n("Your server does not support disabling this setting.") - checked: Config.allowUnknownInvites - enabled: !Config.allowUnknownInvitesImmutable && connection.canCheckMutualRooms - onToggled: { - Config.allowUnknownInvites = checked; - Config.save(); - } - } - } - FormCard.FormHeader { - title: i18nc("@title:group", "Ignored Users") - } - FormCard.FormCard { - FormCard.FormButtonDelegate { - text: i18nc("@action:button", "Manage ignored users") - onClicked: root.ApplicationWindow.window.pageStack.push(ignoredUsersDialogComponent, {}, { - title: i18nc("@title:window", "Ignored Users") - }); - } - } FormCard.FormHeader { title: i18nc("@title", "Keys") } @@ -59,6 +33,17 @@ FormCard.FormCardPage { description: i18n("Device id") } } + FormCard.FormHeader { + title: i18nc("@title:group", "Ignored Users") + } + FormCard.FormCard { + FormCard.FormButtonDelegate { + text: i18nc("@action:button", "Manage ignored users") + onClicked: pageStack.pushDialogLayer(ignoredUsersDialogComponent, {}, { + title: i18nc("@title:window", "Ignored Users") + }); + } + } Component { id: ignoredUsersDialogComponent