mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
refactor: remove unnecessary flag routes added in 9ab1a2d
This commit is contained in:
@@ -148,13 +148,13 @@ define('forum/topic/postTools', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
postContainer.on('click', '[component="post/already-flagged"]', function () {
|
postContainer.on('click', '[component="post/already-flagged"]', function () {
|
||||||
const pid = getData($(this), 'data-pid');
|
const flagId = $(this).data('flag-id');
|
||||||
require(['flags'], function (flags) {
|
require(['flags'], function (flags) {
|
||||||
bootbox.confirm('[[flags:modal-confirm-rescind]]', function (confirm) {
|
bootbox.confirm('[[flags:modal-confirm-rescind]]', function (confirm) {
|
||||||
if (!confirm) {
|
if (!confirm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flags.rescindByType('post', pid);
|
flags.rescind(flagId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,17 +67,6 @@ define('flags', ['hooks', 'components', 'api', 'alerts'], function (hooks, compo
|
|||||||
}).catch(alerts.error);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
Flag.rescindByType = function (type, id) {
|
|
||||||
api.del(`/flags/${type}/${encodeURIComponent(id)}/report`).then(() => {
|
|
||||||
alerts.success('[[flags:rescinded]]');
|
|
||||||
hooks.fire('action:flag.rescinded', { type: type, id: id });
|
|
||||||
if (type === 'post') {
|
|
||||||
const postEl = components.get('post', 'pid', id);
|
|
||||||
postEl.find('[component="post/flag"]').removeClass('hidden').parent().attr('hidden', null);
|
|
||||||
postEl.find('[component="post/already-flagged"]').addClass('hidden').parent().attr('hidden', '');
|
|
||||||
}
|
|
||||||
}).catch(alerts.error);
|
|
||||||
};
|
|
||||||
|
|
||||||
Flag.rescind = function (flagId) {
|
Flag.rescind = function (flagId) {
|
||||||
api.del(`/flags/${flagId}/report`).then(() => {
|
api.del(`/flags/${flagId}/report`).then(() => {
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ Flags.rescind = async (req, res) => {
|
|||||||
await api.flags.rescind(req, { flagId: req.params.flagId });
|
await api.flags.rescind(req, { flagId: req.params.flagId });
|
||||||
helpers.formatApiResponse(200, res);
|
helpers.formatApiResponse(200, res);
|
||||||
};
|
};
|
||||||
Flags.rescindPost = async (req, res) => {
|
|
||||||
await api.flags.rescindPost(req, { pid: req.params.pid });
|
|
||||||
helpers.formatApiResponse(200, res);
|
|
||||||
};
|
|
||||||
Flags.rescindUser = async (req, res) => {
|
|
||||||
await api.flags.rescindUser(req, { uid: req.params.uid });
|
|
||||||
helpers.formatApiResponse(200, res);
|
|
||||||
};
|
|
||||||
|
|
||||||
Flags.appendNote = async (req, res) => {
|
Flags.appendNote = async (req, res) => {
|
||||||
const { note, datetime } = req.body;
|
const { note, datetime } = req.body;
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ module.exports = function () {
|
|||||||
|
|
||||||
setupApiRoute(router, 'delete', '/:flagId/report', middlewares, controllers.write.flags.rescind);
|
setupApiRoute(router, 'delete', '/:flagId/report', middlewares, controllers.write.flags.rescind);
|
||||||
|
|
||||||
setupApiRoute(router, 'delete', '/post/:pid/report', middlewares, controllers.write.flags.rescindPost);
|
|
||||||
setupApiRoute(router, 'delete', '/user/:uid/report', middlewares, controllers.write.flags.rescindUser);
|
|
||||||
|
|
||||||
setupApiRoute(router, 'post', '/:flagId/notes', [...middlewares, middleware.assert.flag], controllers.write.flags.appendNote);
|
setupApiRoute(router, 'post', '/:flagId/notes', [...middlewares, middleware.assert.flag], controllers.write.flags.appendNote);
|
||||||
setupApiRoute(router, 'delete', '/:flagId/notes/:datetime', [...middlewares, middleware.assert.flag], controllers.write.flags.deleteNote);
|
setupApiRoute(router, 'delete', '/:flagId/notes/:datetime', [...middlewares, middleware.assert.flag], controllers.write.flags.deleteNote);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user