Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repost functionality #47

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ The method is used to like a thread. Pass the post id as the first parameter, an
```js
await client.posts.like("aAaAAAaaa", "1")
```
### client.posts.repost
The method is used to repost a thread. Pass the post id as the only parameter
```js
await client.posts.repost("aAaAAAaaa")
```
7 changes: 7 additions & 0 deletions src/managers/PostManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class PostManager extends RESTManager {
});
}

async repost(post) {
return await this.request(`/api/v1/repost/create_repost/`, {
method: 'POST',
body: 'media_id=' + post
});
}

async embed(url) {
return await this.request(`/api/v1/text_feed/link_preview/?url=${encodeURIComponent(url)}`);
}
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ declare module '@threadsjs/threads.js/src/managers/PostManager.js' {
reply(contents: string, user: string, post: string): Promise<any>;
delete(post: string, user: string): Promise<any>;
like(post: string, user: string) : Promise<any>;
repost(post: string) : Promise<any>;
embed(url: string) : Promise<any>;
}
}
Expand Down