moderator-toolbox-nxg-for-reddit / modules/removalreasons/moduleapi

modules/removalreasons/moduleapi

Functions

findSplitChoiceRepairs()

findSplitChoiceRepairs(subreddit, texts): Promise<Map<number, string>>

Defined in: extension/data/modules/removalreasons/moduleapi.ts:85

Finds removal reasons whose mid-sentence choice field an earlier build split onto lines of its own, and the restored text for each. Skipped (returning an empty map) for a subreddit already checked via markChoiceRepairChecked.

Parameters

subreddit

string

The bare subreddit name.

texts

readonly string[]

The current reason texts, by index.

Returns

Promise<Map<number, string>>

Restored text keyed by reason index; empty when there is nothing to repair.

Throws

On a transient wiki read failure (the subreddit is left unchecked).


getNativeReasons()

getNativeReasons(subreddit, options?): Promise<NativeRemovalReason[]>

Defined in: extension/data/modules/removalreasons/moduleapi.ts:44

Fetches a subreddit’s native (Reddit-configured) removal reasons, used both as a fallback for the removal overlay when the subreddit has no Toolbox reasons configured and as the source for the opt-in native reason sync. Kept here so dom.tsx and the sync runner read native reasons through the module’s api layer rather than importing an api/resources module directly.

Parameters

subreddit

string

The bare subreddit name.

options?

Fetch options. fresh bypasses the cache and refreshes it.

fresh?

boolean

Returns

Promise<NativeRemovalReason[]>


getRemovalReasons()

getRemovalReasons(subreddit, allowNonModerated?): Promise<false | RemovalReasonsConfig>

Defined in: extension/data/modules/removalreasons/moduleapi.ts:19

Recursively resolves removal reasons for a subreddit, following getfrom redirects. Returns the removalReasons config object, or false if not configured.

Parameters

subreddit

string

The bare subreddit name.

allowNonModerated?

boolean = false

Read even when the viewer doesn’t moderate the sub. A getfrom redirect can point at a different subreddit the viewer doesn’t moderate (shared removal reasons), which must still resolve; the acting sub keeps the default mod-gate.

Returns

Promise<false | RemovalReasonsConfig>


markChoiceRepairChecked()

markChoiceRepairChecked(subreddit): Promise<void>

Defined in: extension/data/modules/removalreasons/moduleapi.ts:101

Records that a subreddit needs no further split-choice check, after its repair was applied or dismissed (or nothing was found).

Parameters

subreddit

string

The bare subreddit name.

Returns

Promise<void>


saveRemovalConfig()

saveRemovalConfig(subreddit, config, reason): Promise<ConfigSaveResult>

Defined in: extension/data/modules/removalreasons/moduleapi.ts:57

Saves the full toolbox wiki config for a subreddit.

Parameters

subreddit

string

The bare subreddit name.

config

ToolboxConfig

The full toolbox config object.

reason

string

The wiki revision note.

Returns

Promise<ConfigSaveResult>