Implement reporting events
BUG: 458856
This commit is contained in:
@@ -66,6 +66,15 @@ MessageDelegateContextMenu {
|
|||||||
root.closeFullscreen()
|
root.closeFullscreen()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Kirigami.Action {
|
||||||
|
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||||
|
icon.name: "dialog-warning-symbolic"
|
||||||
|
visible: author.id !== currentRoom.localUser.id
|
||||||
|
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/imports/NeoChat/Menu/Timeline/ReportSheet.qml", {room: currentRoom, eventId: eventId}, {
|
||||||
|
title: i18nc("@title", "Report Message"),
|
||||||
|
width: Kirigami.Units.gridUnit * 25
|
||||||
|
})
|
||||||
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18n("View Source")
|
text: i18n("View Source")
|
||||||
icon.name: "code-context"
|
icon.name: "code-context"
|
||||||
|
|||||||
@@ -48,6 +48,15 @@ Loader {
|
|||||||
icon.name: "edit-copy"
|
icon.name: "edit-copy"
|
||||||
onTriggered: Clipboard.saveText(loadRoot.selectedText === "" ? loadRoot.plainMessage : loadRoot.selectedText)
|
onTriggered: Clipboard.saveText(loadRoot.selectedText === "" ? loadRoot.plainMessage : loadRoot.selectedText)
|
||||||
},
|
},
|
||||||
|
Kirigami.Action {
|
||||||
|
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||||
|
icon.name: "dialog-warning-symbolic"
|
||||||
|
visible: author.id !== currentRoom.localUser.id
|
||||||
|
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/imports/NeoChat/Menu/Timeline/ReportSheet.qml", {room: currentRoom, eventId: eventId}, {
|
||||||
|
title: i18nc("@title", "Report Message"),
|
||||||
|
width: Kirigami.Units.gridUnit * 25
|
||||||
|
})
|
||||||
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18n("View Source")
|
text: i18n("View Source")
|
||||||
icon.name: "code-context"
|
icon.name: "code-context"
|
||||||
|
|||||||
47
imports/NeoChat/Menu/Timeline/ReportSheet.qml
Normal file
47
imports/NeoChat/Menu/Timeline/ReportSheet.qml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15 as QQC2
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
|
import org.kde.kirigami 2.20 as Kirigami
|
||||||
|
|
||||||
|
Kirigami.Page {
|
||||||
|
id: reportSheet
|
||||||
|
|
||||||
|
property var room
|
||||||
|
property string eventId
|
||||||
|
|
||||||
|
title: i18n("Report Message")
|
||||||
|
|
||||||
|
QQC2.TextArea {
|
||||||
|
id: reason
|
||||||
|
placeholderText: i18n("Reason for reporting this message")
|
||||||
|
anchors.fill: parent
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
|
}
|
||||||
|
|
||||||
|
footer: QQC2.ToolBar {
|
||||||
|
QQC2.DialogButtonBox {
|
||||||
|
anchors.fill: parent
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||||
|
icon.name: "dialog-warning-symbolic"
|
||||||
|
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
||||||
|
onClicked: {
|
||||||
|
reportSheet.room.reportEvent(eventId, reason.text)
|
||||||
|
reportSheet.closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
text: i18nc("@action", "Cancel")
|
||||||
|
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
|
||||||
|
onClicked: reportSheet.closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,3 +2,4 @@ module NeoChat.Menu.Timeline
|
|||||||
MessageDelegateContextMenu 1.0 MessageDelegateContextMenu.qml
|
MessageDelegateContextMenu 1.0 MessageDelegateContextMenu.qml
|
||||||
FileDelegateContextMenu 1.0 FileDelegateContextMenu.qml
|
FileDelegateContextMenu 1.0 FileDelegateContextMenu.qml
|
||||||
MessageSourceSheet 1.0 MessageSourceSheet.qml
|
MessageSourceSheet 1.0 MessageSourceSheet.qml
|
||||||
|
ReportSheet 1.0 ReportSheet.qml
|
||||||
|
|||||||
@@ -105,17 +105,17 @@ Kirigami.ScrollablePage {
|
|||||||
function onShowMessage(messageType, message) {
|
function onShowMessage(messageType, message) {
|
||||||
page.header.contentItem.text = message;
|
page.header.contentItem.text = message;
|
||||||
page.header.contentItem.type = messageType === ActionsHandler.Error ? Kirigami.MessageType.Error : Kirigami.MessageType.Information;
|
page.header.contentItem.type = messageType === ActionsHandler.Error ? Kirigami.MessageType.Error : Kirigami.MessageType.Information;
|
||||||
page.header.contentItem.visible = true;
|
page.header.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header: QQC2.Control {
|
header: QQC2.Control {
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
visible: contentItem.visible
|
visible: false
|
||||||
padding: Kirigami.Units.smallSpacing
|
padding: Kirigami.Units.smallSpacing
|
||||||
contentItem: Kirigami.InlineMessage {
|
contentItem: Kirigami.InlineMessage {
|
||||||
showCloseButton: true
|
showCloseButton: true
|
||||||
visible: false
|
visible: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +177,15 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: currentRoom
|
||||||
|
function onPositiveMessage(message) {
|
||||||
|
page.header.contentItem.text = message;
|
||||||
|
page.header.contentItem.type = Kirigami.MessageType.Positive;
|
||||||
|
page.header.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// hover actions on a delegate, activated in TimelineContainer.qml
|
// hover actions on a delegate, activated in TimelineContainer.qml
|
||||||
Connections {
|
Connections {
|
||||||
target: page.flickable
|
target: page.flickable
|
||||||
@@ -582,7 +591,7 @@ Kirigami.ScrollablePage {
|
|||||||
function warning(title, message) {
|
function warning(title, message) {
|
||||||
page.header.contentItem.text = `${title}<br />${message}`;
|
page.header.contentItem.text = `${title}<br />${message}`;
|
||||||
page.header.contentItem.type = Kirigami.MessageType.Warning;
|
page.header.contentItem.type = Kirigami.MessageType.Warning;
|
||||||
page.header.contentItem.visible = true;
|
page.header.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showUserDetail(user) {
|
function showUserDetail(user) {
|
||||||
|
|||||||
1
res.qrc
1
res.qrc
@@ -78,6 +78,7 @@
|
|||||||
<file>imports/NeoChat/Menu/Timeline/MessageDelegateContextMenu.qml</file>
|
<file>imports/NeoChat/Menu/Timeline/MessageDelegateContextMenu.qml</file>
|
||||||
<file>imports/NeoChat/Menu/Timeline/FileDelegateContextMenu.qml</file>
|
<file>imports/NeoChat/Menu/Timeline/FileDelegateContextMenu.qml</file>
|
||||||
<file>imports/NeoChat/Menu/Timeline/MessageSourceSheet.qml</file>
|
<file>imports/NeoChat/Menu/Timeline/MessageSourceSheet.qml</file>
|
||||||
|
<file>imports/NeoChat/Menu/Timeline/ReportSheet.qml</file>
|
||||||
<file>imports/NeoChat/Menu/RoomListContextMenu.qml</file>
|
<file>imports/NeoChat/Menu/RoomListContextMenu.qml</file>
|
||||||
<file>qtquickcontrols2.conf</file>
|
<file>qtquickcontrols2.conf</file>
|
||||||
<file>imports/NeoChat/Component/glowdot.png</file>
|
<file>imports/NeoChat/Component/glowdot.png</file>
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include <jobs/downloadfilejob.h>
|
#include <jobs/downloadfilejob.h>
|
||||||
#include <qt_connection_util.h>
|
#include <qt_connection_util.h>
|
||||||
#include <user.h>
|
#include <user.h>
|
||||||
|
#include <csapi/report_content.h>
|
||||||
|
#include <events/eventcontent.h>
|
||||||
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
@@ -1082,3 +1084,13 @@ void NeoChatRoom::updatePushNotificationState(QString type)
|
|||||||
m_currentPushNotificationState = PushNotificationState::Default;
|
m_currentPushNotificationState = PushNotificationState::Default;
|
||||||
Q_EMIT pushNotificationStateChanged(m_currentPushNotificationState);
|
Q_EMIT pushNotificationStateChanged(m_currentPushNotificationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NeoChatRoom::reportEvent(const QString &eventId, const QString &reason)
|
||||||
|
{
|
||||||
|
auto job = connection()->callApi<ReportContentJob>(id(), eventId, -50, reason);
|
||||||
|
connect(job, &BaseJob::finished, this, [this, job]() {
|
||||||
|
if (job->error() == BaseJob::Success) {
|
||||||
|
Q_EMIT positiveMessage(i18n("Report sent successfully."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ public:
|
|||||||
Q_INVOKABLE QString htmlSafeName() const;
|
Q_INVOKABLE QString htmlSafeName() const;
|
||||||
Q_INVOKABLE QString htmlSafeDisplayName() const;
|
Q_INVOKABLE QString htmlSafeDisplayName() const;
|
||||||
Q_INVOKABLE void clearInvitationNotification();
|
Q_INVOKABLE void clearInvitationNotification();
|
||||||
|
Q_INVOKABLE void reportEvent(const QString &eventId, const QString &reason);
|
||||||
|
|
||||||
Q_INVOKABLE void setPushNotificationState(PushNotificationState::State state);
|
Q_INVOKABLE void setPushNotificationState(PushNotificationState::State state);
|
||||||
|
|
||||||
@@ -192,6 +193,7 @@ Q_SIGNALS:
|
|||||||
void isInviteChanged();
|
void isInviteChanged();
|
||||||
void displayNameChanged();
|
void displayNameChanged();
|
||||||
void pushNotificationStateChanged(PushNotificationState::State state);
|
void pushNotificationStateChanged(PushNotificationState::State state);
|
||||||
|
void positiveMessage(const QString &message);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void uploadFile(const QUrl &url, const QString &body = QString());
|
void uploadFile(const QUrl &url, const QString &body = QString());
|
||||||
|
|||||||
Reference in New Issue
Block a user