forked from thislooksfun/snoots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d71a50
commit f5cbf7e
Showing
4 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import BaseControls from "./base"; | ||
|
||
/** The base controls for all content that you can reply to. */ | ||
export default abstract class ReplyableControls extends BaseControls { | ||
/** | ||
* Report an item to the mods. | ||
* | ||
* The report will be anonymous if you are not a mod of the subreddit. If you | ||
* are a mod the report will be tied to your username. | ||
* | ||
* @param id The ID of the item to report. | ||
* @param reason The reason you are reporting the item. | ||
* | ||
* @returns A promise that resolves when the item has been reported. | ||
*/ | ||
async report(id: string, reason?: string): Promise<void> { | ||
await this.client.post("api/report", { | ||
reason: "other", | ||
other_reason: reason, | ||
thing_id: this.namespace(id), | ||
}); | ||
} | ||
|
||
/** @internal */ | ||
async replyImpl<T>(id: string, text: string): Promise<T> { | ||
const body = { text, thing_id: this.namespace(id) }; | ||
return await this.client.post("api/comment", body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { ContentData } from "./content"; | ||
import Content from "./content"; | ||
import ReplyableControls from "../controls/replyable"; | ||
|
||
/** The base for all content that you can reply to. */ | ||
export default abstract class Replyable extends Content { | ||
protected controls: ReplyableControls; | ||
|
||
/** @internal */ | ||
constructor(controls: ReplyableControls, data: ContentData) { | ||
super(data); | ||
this.controls = controls; | ||
} | ||
|
||
/** | ||
* Report this item to the mods. | ||
* | ||
* The report will be anonymous if you are not a mod of the subreddit. If you | ||
* are a mod the report will be tied to your username. | ||
* | ||
* @param reason The reason you are reporting this item. | ||
* | ||
* @returns A promise that resolves when this item has been reported. | ||
*/ | ||
async report(reason?: string): Promise<void> { | ||
await this.controls.report(this.id, reason); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters