add marking threads as read and editing posts

master
John Montagu, the 4th Earl of Sandvich 2024-05-06 22:56:06 -07:00
parent d2180c8717
commit cca7ca2cd7
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
2 changed files with 35 additions and 1 deletions

View File

@ -15,6 +15,7 @@ export class ForumModule extends Module {
"forum.viewposts", "forum.viewposts",
{ {
getSomeBackscroll: reverse, getSomeBackscroll: reverse,
includeThreadMetadata: true,
includePost, includePost,
threadId, threadId,
postId, postId,
@ -31,6 +32,28 @@ export class ForumModule extends Module {
text, text,
threadId, threadId,
} }
) );
}
public async readThread(postId: number, threadId: number) {
return await this.client._call(
TCResponse,
"forum.readthread",
{
postId,
threadId,
}
);
}
public async editPost(postId: number, text: string) {
return await this.client._call(
TCResponse,
"forum.editpost",
{
postId,
text,
}
);
} }
} }

View File

@ -5,6 +5,7 @@ export class ViewPostsResponse extends TCResponse {
numPostsBefore: number; numPostsBefore: number;
numPostsAfter: number; numPostsAfter: number;
jumpTo: number; jumpTo: number;
thread: Thread;
public constructor(response: TCResponseRaw) { public constructor(response: TCResponseRaw) {
super(response); super(response);
@ -12,6 +13,7 @@ export class ViewPostsResponse extends TCResponse {
this.numPostsBefore = response["numPostsBefore"] ?? 0; this.numPostsBefore = response["numPostsBefore"] ?? 0;
this.numPostsAfter = response["numPostsAfter"] ?? 0; this.numPostsAfter = response["numPostsAfter"] ?? 0;
this.jumpTo = response["jumpTo"] ?? 0; this.jumpTo = response["jumpTo"] ?? 0;
this.thread = response["thread"] ?? {};
} }
} }
@ -21,3 +23,12 @@ export interface Post {
readonly text: string; readonly text: string;
readonly time: number; readonly time: number;
} }
export interface Thread {
readonly id: number;
readonly lastPostId: number;
readonly title: string;
readonly locked: boolean;
// TODO: add category
//readonly category
}