diff --git a/CMakeLists.txt b/CMakeLists.txt index 996d3aba..a84f6106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -595,7 +595,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG 8936559c00542528a7776d774fccb7ff674c9c7f + GIT_TAG f878e29420c037f45b575fbd29a11cabce3c010a ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") @@ -772,6 +772,7 @@ set(QML_SOURCES resources/qml/dialogs/RawMessageDialog.qml resources/qml/dialogs/ReadReceipts.qml resources/qml/dialogs/ReCaptchaDialog.qml + resources/qml/dialogs/ReportMessage.qml resources/qml/dialogs/RoomDirectory.qml resources/qml/dialogs/RoomMembers.qml resources/qml/dialogs/AllowedRoomsSettingsDialog.qml diff --git a/im.nheko.Nheko.yaml b/im.nheko.Nheko.yaml index 57772a0c..606b76b7 100644 --- a/im.nheko.Nheko.yaml +++ b/im.nheko.Nheko.yaml @@ -214,7 +214,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: 8936559c00542528a7776d774fccb7ff674c9c7f + - commit: 6e01c75fccc2724fcdfe7a7b1a13547522eb8753 #tag: v0.9.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index df39f3d1..80ec87c2 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -415,6 +415,12 @@ Item { } } } + Component { + id: reportDialog + + ReportMessage {} + } + Platform.MenuItem { enabled: visible text: qsTr("Go to &message") @@ -521,6 +527,16 @@ Item { timelineRoot.destroyOnClose(dialog); } } + Platform.MenuItem { + text: qsTr("Report message") + enabled: visible + onTriggered: function () { + var dialog = reportDialog.createObject(timelineRoot, {"eventId": messageContextMenu.eventId}); + dialog.show(); + dialog.forceActiveFocus(); + timelineRoot.destroyOnClose(dialog); + } + } Platform.MenuItem { enabled: visible text: qsTr("&Save as") diff --git a/resources/qml/dialogs/ReportMessage.qml b/resources/qml/dialogs/ReportMessage.qml new file mode 100644 index 00000000..a0b6325c --- /dev/null +++ b/resources/qml/dialogs/ReportMessage.qml @@ -0,0 +1,85 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import im.nheko + +ApplicationWindow { + required property string eventId + + width: 400 + height: gl.implicitHeight + 2 * Nheko.paddingMedium + title: qsTr("Report message") + + GridLayout { + id: gl + + columnSpacing: Nheko.paddingMedium + rowSpacing: Nheko.paddingMedium + columns: 2 + anchors.fill: parent + anchors.margins: Nheko.paddingMedium + + Label { + Layout.columnSpan: 2 + Layout.fillWidth: true + wrapMode: Label.WordWrap + text: qsTr("This message you are reporting will be sent to your server administrator for review. Please note that not all server administrators review reported content. You should also ask a room moderator to remove the content if necessary.") + } + + Label { + text: qsTr("Enter your reason for reporting:") + } + + TextField { + id: reason + + Layout.fillWidth: true + } + + Label { + text: qsTr("How bad is the message?") + } + + Slider { + id: score + + from: 0 + to: -100 + stepSize: 25 + snapMode: Slider.SnapAlways + Layout.fillWidth: true + } + + Item {} + + Label { + text: { + if (score.value === 0) + return qsTr("Not bad") + else if (score.value === -25) + return qsTr("Mild") + else if (score.value === -50) + return qsTr("Bad") + else if (score.value === -75) + return qsTr("Serious") + else if (score.value === -100) + return qsTr("Extremely serious") + } + } + + DialogButtonBox { + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignRight + standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel + onAccepted: { + room.reportEvent(eventId, reason.text, score.value); + close(); + } + onRejected: close() + } + } +} diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index e8a0a507..aefdc860 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1607,6 +1607,14 @@ TimelineModel::redactAllFromUser(const QString &userid, const QString &reason) std::this_thread::sleep_for(std::chrono::milliseconds(50)); } } + +void +TimelineModel::reportEvent(const QString &eventId, const QString &reason, const int score) +{ + http::client()->report_event( + room_id_.toStdString(), eventId.toStdString(), reason.toStdString(), score); +} + void TimelineModel::redactEvent(const QString &id, const QString &reason) { diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 23c3c802..a3933478 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -333,6 +333,8 @@ public: Q_INVOKABLE void showReadReceipts(const QString &id); Q_INVOKABLE void redactEvent(const QString &id, const QString &reason = ""); Q_INVOKABLE void redactAllFromUser(const QString &userid, const QString &reason = ""); + Q_INVOKABLE void + reportEvent(const QString &eventId, const QString &reason = {}, const int score = -50); Q_INVOKABLE int idToIndex(const QString &id) const; Q_INVOKABLE QString indexToId(int index) const; Q_INVOKABLE void openMedia(const QString &eventId);