feat: add resolve flag to post tools

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 2a939aad8d
commit 52082e1296

@ -6,6 +6,7 @@
"assignee": "Assignee",
"update": "Update",
"updated": "Updated",
"resolved": "Resolved",
"target-purged": "The content this flag referred to has been purged and is no longer available.",
"graph-label": "Daily Flags",

@ -54,6 +54,7 @@
"flag-user": "Flag this user",
"already-flagged": "Already Flagged",
"view-flag-report": "View Flag Report",
"resolve-flag": "Resolve Flag",
"merged_message": "This topic has been merged into <a href=\"%1\">%2</a>",
"deleted_message": "This topic has been deleted. Only users with topic management privileges can see it.",

@ -141,6 +141,13 @@ define('forum/topic/postTools', [
});
});
postContainer.on('click', '[component="post/flagResolve"]', function () {
var flagId = $(this).attr('data-flagId');
require(['flags'], function (flags) {
flags.resolve(flagId);
});
});
postContainer.on('click', '[component="post/edit"]', function () {
var btn = $(this);

@ -1,7 +1,7 @@
'use strict';
define('flags', function () {
define('flags', ['hooks'], function (hooks) {
var Flag = {};
var flagModal;
var flagCommit;
@ -59,6 +59,21 @@ define('flags', function () {
});
};
Flag.resolve = function (flagId) {
socket.emit('flags.update', {
flagId: flagId,
data: [
{ name: 'state', value: 'resolved' },
],
}, function (err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[flags:resolved]]');
hooks.fire('action:flag.resolved', { flagId: flagId });
});
};
function createFlag(type, id, reason) {
if (!type || !id || !reason) {
return;

@ -1,5 +1,6 @@
'use strict';
const db = require('../../database');
const posts = require('../../posts');
const flags = require('../../flags');
const events = require('../../events');
@ -51,6 +52,7 @@ module.exports = function (SocketPosts) {
can: results.canFlag.flag,
exists: !!results.posts.flagId,
flagged: results.flagged,
state: await db.getObjectField(`flag:${postData.flagId}`, 'state'),
};
if (!results.isAdmin && !results.canViewInfo) {

Loading…
Cancel
Save