Node.js based forum software built for the modern web
feat: add resolve flag to post tools
Barış Soner Uşaklı52082e129649
diff --git a/public/language/en-GB/flags.json b/public/language/en-GB/flags.jsonindex 457d80c6d0..17ec52cdf8 100644--- a/public/language/en-GB/flags.json+++ b/public/language/en-GB/flags.json@@ -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",diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.jsonindex 4b381737fd..8955c9f7ef 100644--- a/public/language/en-GB/topic.json+++ b/public/language/en-GB/topic.json@@ -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.",diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.jsindex d89b607879..df739609ba 100644--- a/public/src/client/topic/postTools.js+++ b/public/src/client/topic/postTools.js@@ -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);diff --git a/public/src/modules/flags.js b/public/src/modules/flags.jsindex b22031e956..010d1fa6dc 100644--- a/public/src/modules/flags.js+++ b/public/src/modules/flags.js@@ -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;diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.jsindex 179b795560..7128cfa7d6 100644--- a/src/socket.io/posts/tools.js+++ b/src/socket.io/posts/tools.js@@ -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) {