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

modules/domaintagger/moduleapi

Functions

fetchDomainTagsFromSubreddit()

fetchDomainTagsFromSubreddit(sourceSubreddit): Promise<DomainTag[] | null>

Defined in: extension/data/modules/domaintagger/moduleapi.ts:265

Reads the domain tags from a foreign subreddit for the import feature. Returns only the tag definitions (name, color, note) - counts are never imported.

Parameters

sourceSubreddit

string

The subreddit to read domain tags from.

Returns

Promise<DomainTag[] | null>

The tag array stripped of counts, or null if the subreddit has none configured.


getDomainTagsData()

getDomainTagsData(subreddit): Promise<DomainTagsData>

Defined in: extension/data/modules/domaintagger/moduleapi.ts:55

Reads the domain tags data for a subreddit from its dedicated wiki page, with migration from the legacy ToolboxConfig.domainTags field on first access. Returns a fresh default object when no wiki page exists yet.

Parameters

subreddit

string

The subreddit name.

Returns

Promise<DomainTagsData>


incrementDomainStat()

incrementDomainStat(subreddit, domain, action): Promise<void>

Defined in: extension/data/modules/domaintagger/moduleapi.ts:232

Increments the approval or removal counter for the domain tag that matches the given domain. No-ops silently if no tag matches (untagged domains are not tracked). Uses a read->mutate->write cycle with the per-subreddit save queue.

Parameters

subreddit

string

The subreddit where the mod action occurred.

domain

string

The domain string extracted from the post.

action

"approve" | "remove"

Whether the post was approved or removed.

Returns

Promise<void>


invalidateDomainTagsCache()

invalidateDomainTagsCache(subreddit?): void

Defined in: extension/data/modules/domaintagger/moduleapi.ts:277

Invalidates the in-memory cache for a subreddit so the next read fetches fresh data. Called automatically after successful saves; callers may also call it on demand.

Parameters

subreddit?

string

The subreddit to invalidate, or omit to clear the entire cache.

Returns

void


saveDomainTag()

saveDomainTag(subreddit, domainTag): Promise<void>

Defined in: extension/data/modules/domaintagger/moduleapi.ts:188

Adds, updates, or removes a single domain tag. A tag with color: 'none' removes it. Preserves existing approvalCount, removalCount, and note values on update.

Parameters

subreddit

string

The subreddit whose domain tags to update.

domainTag

DomainTag

The tag to add, update, or remove. approvalCount/removalCount default to 0 for new tags.

Returns

Promise<void>


saveDomainTagsData()

saveDomainTagsData(subreddit, data, reason): Promise<void>

Defined in: extension/data/modules/domaintagger/moduleapi.ts:172

Replaces a subreddit’s entire domain tags page with data (the bulk-editor save). Goes through the same conflict-safe path as the per-tag edits so writes to the page stay serialized; a full replace intentionally supersedes whatever is there.

Parameters

subreddit

string

The subreddit name.

data

DomainTagsData

The complete domain tags data to persist.

reason

string

The wiki revision note.

Returns

Promise<void>

References

DomainTag

Re-exports DomainTag


DomainTagsData

Re-exports DomainTagsData