Skip to content

Commit ada8a15

Browse files
authored
Add likePost method (#112)
1 parent 3111e30 commit ada8a15

File tree

1 file changed

+33
-0
lines changed
  • packages/linejs/base/timeline

1 file changed

+33
-0
lines changed

packages/linejs/base/timeline/mod.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,39 @@ export class Timeline {
400400
{ headers, body: JSON.stringify(data), method: "POST" },
401401
).then((r) => r.json());
402402
}
403+
404+
public async likePost(options: {
405+
contentId: string; // postId
406+
homeId: string;
407+
likeType?: "1003" | "1001" | "1002" | "1004" | "1006" | "1005"; // 1003: GOOD, 1001: LOVE, 1002: FUNNY, 1004: AMAZING, 1006: SAD, 1005: SURPRISED
408+
sourceType?: string;
409+
}): Promise<TimelineResponse> {
410+
await this.initTimeline();
411+
const { contentId, homeId, likeType, sourceType } = {
412+
likeType: "1003",
413+
sourceType: "TIMELINE",
414+
...options,
415+
};
416+
const params = new URLSearchParams({
417+
homeId,
418+
});
419+
const headers = {
420+
...this.timelineHeaders,
421+
"x-lhm": "POST",
422+
};
423+
return await this.client.fetch(
424+
`https://${this.client.request.endpoint}/ext/note/nt/api/v57/like/create.json?${params}`,
425+
{
426+
headers,
427+
method: "POST",
428+
body: JSON.stringify({
429+
sourceType,
430+
likeType,
431+
contentId,
432+
}),
433+
},
434+
).then((r) => r.json());
435+
}
403436

404437
public async sharePost(options: {
405438
postId: string;

0 commit comments

Comments
 (0)