-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
topics.js
82 lines (65 loc) · 2.13 KB
/
topics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const api = require('../../api');
const topics = require('../../topics');
const helpers = require('../helpers');
const Topics = module.exports;
Topics.create = async (req, res) => {
const payload = await api.topics.create(req, req.body);
if (payload.queued) {
helpers.formatApiResponse(202, res, payload);
} else {
helpers.formatApiResponse(200, res, payload);
}
};
Topics.reply = async (req, res) => {
const payload = await api.topics.reply(req, { ...req.body, tid: req.params.tid });
helpers.formatApiResponse(200, res, payload);
};
Topics.delete = async (req, res) => {
await api.topics.delete(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.restore = async (req, res) => {
await api.topics.restore(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.purge = async (req, res) => {
await api.topics.purge(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.pin = async (req, res) => {
await api.topics.pin(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.unpin = async (req, res) => {
await api.topics.unpin(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.lock = async (req, res) => {
await api.topics.lock(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.unlock = async (req, res) => {
await api.topics.unlock(req, { tids: [req.params.tid] });
helpers.formatApiResponse(200, res);
};
Topics.follow = async (req, res) => {
await api.topics.follow(req, req.params);
helpers.formatApiResponse(200, res);
};
Topics.ignore = async (req, res) => {
await api.topics.ignore(req, req.params);
helpers.formatApiResponse(200, res);
};
Topics.unfollow = async (req, res) => {
await api.topics.unfollow(req, req.params);
helpers.formatApiResponse(200, res);
};
Topics.addTags = async (req, res) => {
await topics.createTags(req.body.tags, req.params.tid, Date.now());
helpers.formatApiResponse(200, res);
};
Topics.deleteTags = async (req, res) => {
await topics.deleteTopicTags(req.params.tid);
helpers.formatApiResponse(200, res);
};