refactor: remove unnecessary flag routes added in 9ab1a2d

This commit is contained in:
Opliko
2024-04-30 00:39:32 +02:00
parent b9d6aa4639
commit 53b352d0d8
4 changed files with 2 additions and 24 deletions

View File

@@ -148,13 +148,13 @@ define('forum/topic/postTools', [
});
postContainer.on('click', '[component="post/already-flagged"]', function () {
const pid = getData($(this), 'data-pid');
const flagId = $(this).data('flag-id');
require(['flags'], function (flags) {
bootbox.confirm('[[flags:modal-confirm-rescind]]', function (confirm) {
if (!confirm) {
return;
}
flags.rescindByType('post', pid);
flags.rescind(flagId);
});
});
});

View File

@@ -67,17 +67,6 @@ define('flags', ['hooks', 'components', 'api', 'alerts'], function (hooks, compo
}).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) {
api.del(`/flags/${flagId}/report`).then(() => {

View File

@@ -36,14 +36,6 @@ Flags.rescind = async (req, res) => {
await api.flags.rescind(req, { flagId: req.params.flagId });
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) => {
const { note, datetime } = req.body;

View File

@@ -19,9 +19,6 @@ module.exports = function () {
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, 'delete', '/:flagId/notes/:datetime', [...middlewares, middleware.assert.flag], controllers.write.flags.deleteNote);