Revert "Allow blocking invites from people you don't share a room with"
This reverts commit ef5585d312. This was
supposed to be in an MR.
This commit is contained in:
@@ -134,8 +134,6 @@ add_library(neochat STATIC
|
|||||||
jobs/neochatdeletedevicejob.h
|
jobs/neochatdeletedevicejob.h
|
||||||
jobs/neochatchangepasswordjob.cpp
|
jobs/neochatchangepasswordjob.cpp
|
||||||
jobs/neochatchangepasswordjob.h
|
jobs/neochatchangepasswordjob.h
|
||||||
jobs/neochatgetcommonroomsjob.cpp
|
|
||||||
jobs/neochatgetcommonroomsjob.h
|
|
||||||
mediasizehelper.cpp
|
mediasizehelper.cpp
|
||||||
mediasizehelper.h
|
mediasizehelper.h
|
||||||
eventhandler.cpp
|
eventhandler.cpp
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "neochatgetcommonroomsjob.h"
|
|
||||||
|
|
||||||
using namespace Quotient;
|
|
||||||
|
|
||||||
NeochatGetCommonRoomsJob::NeochatGetCommonRoomsJob(const QString &userId, const Omittable<QJsonObject> &auth)
|
|
||||||
: BaseJob(HttpVerb::Get,
|
|
||||||
QStringLiteral("GetCommonRoomsJob"),
|
|
||||||
QStringLiteral("/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms").toLatin1(),
|
|
||||||
QUrlQuery({{QStringLiteral("user_id"), userId}}))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Quotient/jobs/basejob.h>
|
|
||||||
#include <Quotient/omittable.h>
|
|
||||||
|
|
||||||
// TODO: Upstream to libQuotient
|
|
||||||
class NeochatGetCommonRoomsJob : public Quotient::BaseJob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit NeochatGetCommonRoomsJob(const QString &userId, const Quotient::Omittable<QJsonObject> &auth = {});
|
|
||||||
};
|
|
||||||
@@ -187,11 +187,5 @@
|
|||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
<group name="Security">
|
|
||||||
<entry name="AllowUnknownInvites" type="bool">
|
|
||||||
<label>Allow unknown invites</label>
|
|
||||||
<default>true</default>
|
|
||||||
</entry>
|
|
||||||
</group>
|
|
||||||
</kcfg>
|
</kcfg>
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <Quotient/csapi/content-repo.h>
|
#include <Quotient/csapi/content-repo.h>
|
||||||
#include <Quotient/csapi/profile.h>
|
#include <Quotient/csapi/profile.h>
|
||||||
#include <Quotient/csapi/versions.h>
|
|
||||||
#include <Quotient/database.h>
|
#include <Quotient/database.h>
|
||||||
#include <Quotient/jobs/downloadfilejob.h>
|
#include <Quotient/jobs/downloadfilejob.h>
|
||||||
#include <Quotient/qt_connection_util.h>
|
#include <Quotient/qt_connection_util.h>
|
||||||
@@ -133,20 +132,6 @@ void NeoChatConnection::connectSignals()
|
|||||||
Q_EMIT homeNotificationsChanged();
|
Q_EMIT homeNotificationsChanged();
|
||||||
Q_EMIT homeHaveHighlightNotificationsChanged();
|
Q_EMIT homeHaveHighlightNotificationsChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch unstable features
|
|
||||||
// TODO: Expose unstableFeatures() in libQuotient
|
|
||||||
connect(
|
|
||||||
this,
|
|
||||||
&Connection::connected,
|
|
||||||
this,
|
|
||||||
[this] {
|
|
||||||
callApi<GetVersionsJob>(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
|
int NeoChatConnection::badgeNotificationCount() const
|
||||||
@@ -215,11 +200,6 @@ QVariantList NeoChatConnection::getSupportedRoomVersions() const
|
|||||||
return supportedRoomVersions;
|
return supportedRoomVersions;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NeoChatConnection::canCheckMutualRooms() const
|
|
||||||
{
|
|
||||||
return m_canCheckMutualRooms;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NeoChatConnection::changePassword(const QString ¤tPassword, const QString &newPassword)
|
void NeoChatConnection::changePassword(const QString ¤tPassword, const QString &newPassword)
|
||||||
{
|
{
|
||||||
auto job = callApi<NeochatChangePasswordJob>(newPassword, false);
|
auto job = callApi<NeochatChangePasswordJob>(newPassword, false);
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ class NeoChatConnection : public Quotient::Connection
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool isOnline READ isOnline WRITE setIsOnline NOTIFY isOnlineChanged)
|
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:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Defines the status after an attempt to change the password on an account.
|
* @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 void logout(bool serverSideLogout);
|
||||||
Q_INVOKABLE QVariantList getSupportedRoomVersions() const;
|
Q_INVOKABLE QVariantList getSupportedRoomVersions() const;
|
||||||
bool canCheckMutualRooms() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Change the password for an account.
|
* @brief Change the password for an account.
|
||||||
@@ -202,7 +196,6 @@ Q_SIGNALS:
|
|||||||
void passwordStatus(NeoChatConnection::PasswordStatus status);
|
void passwordStatus(NeoChatConnection::PasswordStatus status);
|
||||||
void userConsentRequired(QUrl url);
|
void userConsentRequired(QUrl url);
|
||||||
void badgeNotificationCountChanged(NeoChatConnection *connection, int count);
|
void badgeNotificationCountChanged(NeoChatConnection *connection, int count);
|
||||||
void canCheckMutualRoomsChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isOnline = true;
|
bool m_isOnline = true;
|
||||||
@@ -215,6 +208,4 @@ private:
|
|||||||
int m_badgeNotificationCount = 0;
|
int m_badgeNotificationCount = 0;
|
||||||
|
|
||||||
QHash<QUrl, LinkPreviewer *> m_linkPreviewers;
|
QHash<QUrl, LinkPreviewer *> m_linkPreviewers;
|
||||||
|
|
||||||
bool m_canCheckMutualRooms = false;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include "events/joinrulesevent.h"
|
#include "events/joinrulesevent.h"
|
||||||
#include "events/pollevent.h"
|
#include "events/pollevent.h"
|
||||||
#include "filetransferpseudojob.h"
|
#include "filetransferpseudojob.h"
|
||||||
#include "jobs/neochatgetcommonroomsjob.h"
|
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
#include "notificationsmanager.h"
|
#include "notificationsmanager.h"
|
||||||
#include "roomlastmessageprovider.h"
|
#include "roomlastmessageprovider.h"
|
||||||
@@ -130,38 +129,14 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto roomMemberEvent = currentState().get<RoomMemberEvent>(localMember().id());
|
auto roomMemberEvent = currentState().get<RoomMemberEvent>(localMember().id());
|
||||||
|
QImage avatar_image;
|
||||||
auto showNotification = [this, roomMemberEvent] {
|
if (roomMemberEvent && !member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) {
|
||||||
QImage avatar_image;
|
avatar_image = memberAvatar(roomMemberEvent->senderId()).get(this->connection(), 128, [] {});
|
||||||
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();
|
|
||||||
} else {
|
} else {
|
||||||
auto job = this->connection()->callApi<NeochatGetCommonRoomsJob>(roomMemberEvent->senderId());
|
qWarning() << "using this room's avatar";
|
||||||
connect(job, &BaseJob::result, this, [this, job, roomMemberEvent, showNotification] {
|
avatar_image = avatar(128);
|
||||||
QJsonObject replyData = job->jsonData();
|
|
||||||
if (replyData.contains(QStringLiteral("joined"))) {
|
|
||||||
const bool inAnyOfOurRooms = !replyData[QStringLiteral("joined")].toArray().isEmpty();
|
|
||||||
if (inAnyOfOurRooms) {
|
|
||||||
showNotification();
|
|
||||||
} else {
|
|
||||||
leaveRoom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
NotificationsManager::instance().postInviteNotification(this, displayName(), member(roomMemberEvent->senderId()).htmlSafeDisplayName(), avatar_image);
|
||||||
},
|
},
|
||||||
Qt::SingleShotConnection);
|
Qt::SingleShotConnection);
|
||||||
connect(this, &Room::changed, this, [this] {
|
connect(this, &Room::changed, this, [this] {
|
||||||
|
|||||||
@@ -16,32 +16,6 @@ FormCard.FormCardPage {
|
|||||||
|
|
||||||
title: i18nc("@title", "Security")
|
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 {
|
FormCard.FormHeader {
|
||||||
title: i18nc("@title", "Keys")
|
title: i18nc("@title", "Keys")
|
||||||
}
|
}
|
||||||
@@ -59,6 +33,17 @@ FormCard.FormCardPage {
|
|||||||
description: i18n("Device id")
|
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 {
|
Component {
|
||||||
id: ignoredUsersDialogComponent
|
id: ignoredUsersDialogComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user