Skip to content

Commit f67ea2d

Browse files
committed
Added support for handling bans in stories
1 parent 92b2e34 commit f67ea2d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

js/Akun.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ class Akun {
193193
return this._closeNode(readerPostNodeId);
194194
}
195195

196+
ban(storyId, postId) {
197+
return this.core.post(`/api/anonkun/ban`, {
198+
blockFor: postId,
199+
blockFrom: storyId
200+
}, false);
201+
}
202+
203+
unban(storyId, postId) {
204+
return this.core.delete(`/api/anonkun/ban`, {
205+
blockFor: postId,
206+
blockFrom: storyId
207+
}, false);
208+
}
209+
210+
getBans(storyId) {
211+
return this.core.get(`/api/anonkun/story/bans/${storyId}`);
212+
}
213+
196214
_openNode(nodeId) {
197215
return this.core.post(`/api/anonkun/editChapter`, {
198216
'_id': nodeId,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akun-api",
3-
"version": "4.0.3",
3+
"version": "4.1.0",
44
"description": "A module intended to enable easy interactions with Anonkun",
55
"main": "index.js",
66
"type": "module",

test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,25 @@ async function testPost(akun, chatId) {
190190
// console.log(await client.reply('rooply', 't2KXjRztofE5Z58uE'));
191191
}
192192

193+
async function testBan(akun) {
194+
let res;
195+
res = await akun.login(credentials['username'], credentials['password']);
196+
console.log(res);
197+
res = await akun.unban('iRoYFFCDCZnB2QvEq', '53zAELYaC8RkkMpcn');
198+
console.log(res);
199+
res = await akun.unban('iRoYFFCDCZnB2QvEq', 'B5cqvTk3kMgRNPesr');
200+
console.log(res);
201+
}
202+
193203
async function runTests(akun) {
194204
// await testAnonToggle(akun, 'vhHhMfskRnNDbxwzo');
195205
// await testPost(akun, 'vhHhMfskRnNDbxwzo');
196-
await testStory(akun, 'vhHhMfskRnNDbxwzo');
206+
// await testStory(akun, 'vhHhMfskRnNDbxwzo');
197207
// await testChat(akun, 'oQ2fkvRS4nxjLfSmA');
198208
// await testChat(akun, 'oWC3WhFDMXqZkAG69');
199209
// await testPut(akun, 'vhHhMfskRnNDbxwzo');
200210
// await testVote(akun, 'TziTddJsppEfr82nh');
211+
// await testBan(akun);
201212
}
202213

203214
async function setup(withRealtime = true) {

0 commit comments

Comments
 (0)