/
xhr.ts
38 lines (32 loc) · 855 Bytes
/
xhr.ts
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
import { json, text, form } from 'common/xhr';
export const userModInfo = (username: string) => json('/mod/chat-user/' + username);
export const flag = (resource: string, username: string, text: string) =>
json('/report/flag', {
method: 'post',
body: form({ username, resource, text }),
});
export const getNote = (id: string) => text(noteUrl(id));
export const setNote = (id: string, text: string) =>
json(noteUrl(id), {
method: 'post',
body: form({ text }),
});
const noteUrl = (id: string) => `/${id}/note`;
export const timeout = (
resourceId: string,
body: {
userId: string;
reason: string;
text: string;
},
) => {
const [chan, roomId] = resourceId.split('/');
return text(`/mod/public-chat/timeout`, {
method: 'post',
body: form({
...body,
chan,
roomId,
}),
});
};