moderator-toolbox-nxg-for-reddit / util/reddit/thingInfo
util/reddit/thingInfo¶
Functions¶
getApiThingInfo()¶
getApiThingInfo(
subreddit,fullname,modCheck?):Promise<ThingInfo>
Defined in: extension/data/util/reddit/thingInfo.ts:115
Fetches thing info from the Reddit API and normalizes it into a flat object used by modules.
Parameters¶
subreddit¶
string
Subreddit context for the request.
fullname¶
string
Fullname of the thing (e.g. t3_abc123).
modCheck?¶
boolean
When true, returns an empty subreddit field if the current user is not a mod there.
Returns¶
Promise<ThingInfo>
getThingInfo()¶
getThingInfo(
sender,modCheck?):Promise<ThingInfo|null>
Defined in: extension/data/util/reddit/thingInfo.ts:190
Extracts thing info from a Toolbox-rendered DOM element (.toolbox-thing).
Parameters¶
sender¶
Element | null
Any element inside a .toolbox-thing; the nearest ancestor is used.
modCheck?¶
boolean
When true, returns null if the current user is not a mod in the thing’s subreddit.
Returns¶
Promise<ThingInfo | null>
isInfoRemoved()¶
isInfoRemoved(
info):boolean
Defined in: extension/data/util/reddit/thingInfo.ts:105
Whether a thing’s normalized info (from getApiThingInfo) indicates it is currently
removed or spammed. ham (Reddit’s “removed” flag) isn’t reliably populated by /api/info, so
spam and banned_by are ORed in to also catch queue-removed/spammed items.
Parameters¶
info¶
Normalized thing info exposing the ham/spam/banned_by fields.
banned_by?¶
unknown
ham?¶
unknown
spam?¶
unknown
Returns¶
boolean
Classes¶
ThingNotFoundError¶
Defined in: extension/data/util/reddit/thingInfo.ts:82
Thrown by getApiThingInfo when the Reddit API returns an empty listing for a
fullname - a definitive “not found” (deleted/removed thing), as opposed to a transient
error. Callers can branch on instanceof ThingNotFoundError instead of matching the
message text.
Extends¶
Error
Constructors¶
Constructor¶
new ThingNotFoundError(
fullname,subreddit):ThingNotFoundError
Defined in: extension/data/util/reddit/thingInfo.ts:83
Parameters¶
fullname¶
string
subreddit¶
string
Returns¶
Overrides¶
Error.constructor
Methods¶
isError()¶
staticisError(error):error is Error
Defined in: node_modules/typescript/lib/lib.esnext.error.d.ts:21
Indicates whether the argument provided is a built-in Error instance or not.
Parameters¶
error¶
unknown
Returns¶
error is Error
Inherited from¶
Error.isError
Properties¶
cause?¶
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from¶
Error.cause
message¶
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from¶
Error.message
name¶
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from¶
Error.name
stack?¶
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from¶
Error.stack
Interfaces¶
ThingInfo¶
Defined in: extension/data/util/reddit/thingInfo.ts:41
Normalized, flat thing (submission/comment) info produced by getApiThingInfo (from the Reddit API) and getThingInfo (from a Toolbox-rendered DOM element). Fields absent from one producer or the other are optional.
Indexable¶
[
key:string]:unknown
Properties¶
approved_by?¶
optionalapproved_by?:string|null
Defined in: extension/data/util/reddit/thingInfo.ts:53
banned_by?¶
optionalbanned_by?:string|boolean|null
Defined in: extension/data/util/reddit/thingInfo.ts:59
body¶
body:
string
Defined in: extension/data/util/reddit/thingInfo.ts:50
domain¶
domain:
string
Defined in: extension/data/util/reddit/thingInfo.ts:47
fullname¶
fullname:
string
Defined in: extension/data/util/reddit/thingInfo.ts:48
ham?¶
optionalham?:string|boolean
Defined in: extension/data/util/reddit/thingInfo.ts:61
id¶
id:
string
Defined in: extension/data/util/reddit/thingInfo.ts:49
kind¶
kind:
"comment"|"submission"
Defined in: extension/data/util/reddit/thingInfo.ts:56
link¶
link:
string
Defined in: extension/data/util/reddit/thingInfo.ts:58
mod¶
mod:
string
Defined in: extension/data/util/reddit/thingInfo.ts:65
modReports?¶
optionalmodReports?: [string,string][]
Defined in: extension/data/util/reddit/thingInfo.ts:67
modReportsDismissed?¶
optionalmodReportsDismissed?: [string,string][]
Defined in: extension/data/util/reddit/thingInfo.ts:69
permalink¶
permalink:
string
Defined in: extension/data/util/reddit/thingInfo.ts:45
postlink¶
postlink:
string
Defined in: extension/data/util/reddit/thingInfo.ts:57
raw_body¶
raw_body:
string
Defined in: extension/data/util/reddit/thingInfo.ts:51
reportsIgnored?¶
optionalreportsIgnored?:boolean
Defined in: extension/data/util/reddit/thingInfo.ts:70
rules¶
rules:
string
Defined in: extension/data/util/reddit/thingInfo.ts:62
spam?¶
optionalspam?:string|boolean
Defined in: extension/data/util/reddit/thingInfo.ts:60
subreddit¶
subreddit:
string
Defined in: extension/data/util/reddit/thingInfo.ts:42
title¶
title:
string
Defined in: extension/data/util/reddit/thingInfo.ts:54
uri_body¶
uri_body:
string
Defined in: extension/data/util/reddit/thingInfo.ts:52
uri_title¶
uri_title:
string
Defined in: extension/data/util/reddit/thingInfo.ts:55
url¶
url:
string
Defined in: extension/data/util/reddit/thingInfo.ts:46
user¶
user:
string
Defined in: extension/data/util/reddit/thingInfo.ts:43
userReports?¶
optionaluserReports?: [string,string][]
Defined in: extension/data/util/reddit/thingInfo.ts:66
userReportsDismissed?¶
optionaluserReportsDismissed?: [string,string][]
Defined in: extension/data/util/reddit/thingInfo.ts:68
wiki¶
wiki:
string
Defined in: extension/data/util/reddit/thingInfo.ts:64