mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Add report message functionality
This commit is contained in:
parent
bbfbba30b0
commit
bb971b0575
6 changed files with 114 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
85
resources/qml/dialogs/ReportMessage.qml
Normal file
85
resources/qml/dialogs/ReportMessage.qml
Normal file
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue