|
1 | 1 | // deno-lint-ignore-file no-explicit-any |
2 | 2 | import type { BaseClient } from "../mod.ts"; |
| 3 | +import type { LooseType } from "@evex/loose-types"; |
3 | 4 |
|
4 | | -export type TimelineResponse<T = any> = { |
| 5 | +export type TimelineResponse<T = LooseType> = { |
5 | 6 | code: number; |
6 | 7 | message: string; |
7 | 8 | result: T; |
@@ -102,7 +103,7 @@ export class Timeline { |
102 | 103 | homeId: homeId, |
103 | 104 | sourceType: sourceType, |
104 | 105 | }); |
105 | | - const postInfo: any = { |
| 106 | + const postInfo: LooseType = { |
106 | 107 | readPermission: { |
107 | 108 | type: readPermissionType, |
108 | 109 | gids: readPermissionGids, |
@@ -146,7 +147,7 @@ export class Timeline { |
146 | 147 | obsFace: "[]", |
147 | 148 | }); |
148 | 149 | }); |
149 | | - const contents: any = { |
| 150 | + const contents: LooseType = { |
150 | 151 | contentsStyle: { |
151 | 152 | textStyle: { |
152 | 153 | textSizeMode: textSizeMode, |
@@ -314,7 +315,7 @@ export class Timeline { |
314 | 315 | if (!postId) { |
315 | 316 | throw new Error("postId is required"); |
316 | 317 | } |
317 | | - const postInfo: any = { |
| 318 | + const postInfo: LooseType = { |
318 | 319 | postId: postId, |
319 | 320 | editableContents: ["ALL"], |
320 | 321 | readPermission: { |
@@ -359,7 +360,7 @@ export class Timeline { |
359 | 360 | obsFace: "[]", |
360 | 361 | }); |
361 | 362 | }); |
362 | | - const contents: any = { |
| 363 | + const contents: LooseType = { |
363 | 364 | sticonMetas: [], |
364 | 365 | contentsStyle: { |
365 | 366 | textStyle: textSizeMode || textAnimation ? { |
@@ -433,6 +434,42 @@ export class Timeline { |
433 | 434 | }, |
434 | 435 | ).then((r) => r.json()); |
435 | 436 | } |
| 437 | + |
| 438 | + public async createComment(options: { |
| 439 | + contentId: string; // postId |
| 440 | + commentText: string; |
| 441 | + homeId: string; |
| 442 | + sourceType?: string; |
| 443 | + contentsList?: LooseType[]; |
| 444 | + }): Promise<TimelineResponse> { |
| 445 | + await this.initTimeline(); |
| 446 | + const { contentId, commentText, homeId, sourceType, contentsList } = { |
| 447 | + sourceType: "TIMELINE", |
| 448 | + contentsList: [], |
| 449 | + ...options, |
| 450 | + }; |
| 451 | + const params = new URLSearchParams({ |
| 452 | + sourceType, |
| 453 | + homeId, |
| 454 | + }); |
| 455 | + const headers = { |
| 456 | + ...this.timelineHeaders, |
| 457 | + "x-lhm": "POST", |
| 458 | + }; |
| 459 | + const body = { |
| 460 | + commentText, |
| 461 | + contentId, |
| 462 | + contentsList, |
| 463 | + }; |
| 464 | + return await this.client.fetch( |
| 465 | + `https://${this.client.request.endpoint}/ext/note/nt/api/v57/comment/create.json?${params}`, |
| 466 | + { |
| 467 | + headers, |
| 468 | + method: "POST", |
| 469 | + body: JSON.stringify(body), |
| 470 | + }, |
| 471 | + ).then((r) => r.json()); |
| 472 | + } |
436 | 473 |
|
437 | 474 | public async sharePost(options: { |
438 | 475 | postId: string; |
|
0 commit comments