Constructor
new Toot()
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
accounts |
Array.<Account> | Array with the author of the toot and (if it exists) the account that retooted it. | |
ageInHours |
number | Age of this toot in hours. | |
allEmojis |
Array.<mastodon.v1.CustomEmoji> | All custom emojis in the toot, including the author's. | |
attachmentType |
MediaAttachmentType |
<optional> |
The type of media in the toot (image, video, audio, etc.). |
author |
Account | The account that posted this toot, not the account that reblogged it. | |
completedAt |
string |
<optional> |
Timestamp when a full deep inspection of the toot was last completed. |
contentTagsParagraph |
string |
<optional> |
If the last paragraph is 100% hashtag this is the HTML for that paragraph. |
description |
string | A string describing the toot, including author, content, and createdAt. | |
followedTags |
Array.<MastodonTag> |
<optional> |
Array of tags that the user follows that exist in this toot. |
homeserver |
string | The homeserver of the author of the toot. | |
isDM |
boolean | True if the toot is a direct message (DM) to the user. | |
isFollowed |
boolean | True if this toot is from a followed account or contains a followed tag. | |
isLocal |
boolean | True if this toot is from the FediAlgo user's home server. | |
isPrivate |
boolean | True if it's for followers only. | |
isTrending |
boolean | True if it's a trending toot or contains any trending hashtags or links. | |
lastEditedAt |
string | The date when the toot was last edited, or createdAt if never edited. | |
numTimesShown |
number |
<optional> |
Managed in client app. # of times the Toot has been shown to the user. |
participatedTags |
Array.<TagWithUsageCounts> |
<optional> |
Tags that the user has participated in that exist in this toot |
popularity |
number | Sum of the trendingRank, numReblogs, replies, and local server favourites. Currently unused. | |
realToot |
module:api/objects/toot~Toot | The toot that was reblogged if it's a reblog, otherwise this toot. | |
realURI |
string | URI for the realToot. | |
realURL |
string | Default to this.realURI if url property is empty. | |
reblog |
SerializableToot | null |
<optional> |
The toot that was retooted (if any). |
reblogsBy |
Array.<AccountLike> |
<optional> |
The accounts that retooted this toot (if any) |
replyMentions |
Array.<string> | The webfinger URIs of the accounts mentioned in the toot + the author prepended with @. | |
resolvedID |
string |
<optional> |
This Toot with URLs resolved to homeserver versions |
score |
number | Current overall score for this toot. | |
scoreInfo |
TootScore |
<optional> |
Scoring info for weighting/sorting this toot |
sources |
Array.<string> |
<optional> |
Source of the toot (e.g. trending tag toots, home timeline, etc.) |
tootedAt |
Date | Timestamp of toot's createdAt. | |
trendingLinks |
Array.<TrendingLink> |
<optional> |
Links that are trending in this toot |
trendingRank |
number |
<optional> |
Most trending on a server gets a 10, next is a 9, etc. |
trendingTags |
Array.<TagWithUsageCounts> |
<optional> |
Tags that are trending in this toot |
withRetoot |
Array.<module:api/objects/toot~Toot> | Returns the toot and the retoot, if it exists, as an array. | |
audioAttachments |
Array.<mastodon.v1.MediaAttachment> |
<optional> |
|
imageAttachments |
Array.<mastodon.v1.MediaAttachment> |
<optional> |
|
videoAttachments |
Array.<mastodon.v1.MediaAttachment> |
<optional> |
- Implements:
- TootObj
Extends
- mastodon.v1.Status
Methods
containsString(str) → {boolean}
True if toot contains
str
in the tags, the content, or the link preview card description.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to search for. |
Returns:
- Type
- boolean
containsTag(tag, fullScanopt) → {boolean}
Return true if the toot contains the tag or hashtag. If fullScan is true uses containsString() to search.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tag |
TagWithUsageCounts | The tag to search for. | |
fullScan |
boolean |
<optional> |
Whether to use full scan. |
Returns:
- Type
- boolean
containsTagsMsg() → {string|undefined}
Generate a string describing the followed, trending, and participated tags in the toot.
TODO: add favourited tags?
Returns:
- Type
- string | undefined
containsUserMention() → {boolean}
Returns
true
if the fedialgo user is mentioned in this Toot
.
Returns:
- Type
- boolean
contentNonTagsParagraphs(fontSizeopt) → {string}
Return all but the last paragraph if that last paragraph is just hashtag links.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fontSize |
number |
<optional> |
DEFAULT_FONT_SIZE | Size in pixels of any emoji <img> tags. Should match surrounding txt. |
Returns:
- Type
- string
contentParagraphs(fontSizeopt) → {Array.<string>}
Break up the content into paragraphs and add <img> tags for custom emojis.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fontSize |
number |
<optional> |
DEFAULT_FONT_SIZE | Size in pixels of any emoji <img> tags. Should match surrounding txt. |
Returns:
- Type
- Array.<string>
contentShortened(maxCharsopt) → {string}
Shortened string of content property stripped of HTML tags.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
maxChars |
number |
<optional> |
Returns:
- Type
- string
contentWithEmojis(fontSizeopt) → {string}
Replace custom emoji shortcodes (e.g. ":myemoji:") with image tags.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fontSize |
number |
<optional> |
DEFAULT_FONT_SIZE | Size in pixels of any emoji imgs. Should match surrounding text. |
Returns:
- Type
- string
(async) getConversation() → {Promise.<Array.<module:api/objects/toot~Toot>>}
Fetch the conversation for this toot (Mastodon API calls this a
Context).
Returns:
- Type
- Promise.<Array.<module:api/objects/toot~Toot>>
getIndividualScore(scoreType, name) → {number}
Get an individual score for this
Toot
.
Parameters:
Name | Type | Description |
---|---|---|
scoreType |
ScoreType | The score type. |
name |
ScoreName | The score name. |
Returns:
- Type
- number
isInTimeline(filters) → {boolean}
Return true if the
Toot
should not be filtered out of the feed by the current filters.
Parameters:
Name | Type | Description |
---|---|---|
filters |
FeedFilterSettings | The feed filter settings. |
Returns:
- Type
- boolean
isValidForFeed(serverSideFilters) → {boolean}
Return false if
Toot
should be discarded from feed altogether and permanently.
Parameters:
Name | Type | Description |
---|---|---|
serverSideFilters |
Array.<mastodon.v2.Filter> | Server-side filters. |
Returns:
- Type
- boolean
(async) localServerUrl() → {Promise.<string>}
Make an API call to get this
Toot
's URL on the FediAlgo user's home server instead of on
the Toot
's home server.
Returns:
The home server URL.
- Type
- Promise.<string>
Example
"https://fosstodon.org/@kate/114360290341300577" => "https://universeodon.com/@kate@fosstodon.org/114360290578867339"
matchesRegex(regex) → {boolean}
True if
Toot
matches regex
in the tags, the content, or the link preview card description.
Parameters:
Name | Type | Description |
---|---|---|
regex |
RegExp | The string to search for. |
Returns:
- Type
- boolean
(async) resolve() → {Promise.<module:api/objects/toot~Toot>}
Returns:
- Type
- Promise.<module:api/objects/toot~Toot>
(async) resolveID() → {Promise.<string>}
Returns:
- Type
- Promise.<string>
tagNames() → {Set.<string>}
Get the
Toot
's tags as a Set
of strings. Caches results for future calls.
Returns:
Set of the names of the tags in this toot.
- Type
- Set.<string>
(static) build(toot) → {module:api/objects/toot~Toot}
Alternate constructor because class-transformer doesn't work with constructor arguments.
Parameters:
Name | Type | Description |
---|---|---|
toot |
SerializableToot | The toot data to build from. |
Returns:
The constructed Toot instance.
- Type
- module:api/objects/toot~Toot
(async, static) buildToots(statuses, source) → {Promise.<Array.<module:api/objects/toot~Toot>>}
Build array of new
Toot
objects from an array of
Status objects (or Toot
s).
Toot
s returned are sorted by score and should have most of their properties set correctly.
Parameters:
Name | Type | Description |
---|---|---|
statuses |
Array.<TootLike> | Array of status objects or Toots. |
source |
TootSource | The source label for logging. |
Returns:
- Type
- Promise.<Array.<module:api/objects/toot~Toot>>
(async, static) completeToots(toots, logger, sourceopt) → {Promise.<Array.<module:api/objects/toot~Toot>>}
Fetch all the data we need to set dependent properties and set them on the toots.
If
source
arg is provided we set it as the Toot.source
prop and avoid doing an
Toot.isDeepInspect
completion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
toots |
Array.<TootLike> | Array of toots to complete. | |
logger |
Logger | Logger for logging. | |
source |
string |
<optional> |
Optional source label. |
Returns:
- Type
- Promise.<Array.<module:api/objects/toot~Toot>>
(static) dedupeToots(toots, inLoggeropt) → {Array.<module:api/objects/toot~Toot>}
Remove dupes by uniquifying on the
Toot
's URI.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
toots |
Array.<module:api/objects/toot~Toot> | Array of toots. | |
inLogger |
Logger |
<optional> |
Logger for logging. |
Returns:
Deduped array of toots.
- Type
- Array.<module:api/objects/toot~Toot>
(static) onlyReplies(toots) → {Array.<module:api/objects/toot~Toot>}
Filter an array of
Toot
s down to just the replies.
Parameters:
Name | Type | Description |
---|---|---|
toots |
Array.<module:api/objects/toot~Toot> | Array of toots. |
Returns:
Array of replies.
- Type
- Array.<module:api/objects/toot~Toot>
(static) onlyRetoots(toots) → {Array.<module:api/objects/toot~Toot>}
Filter an array of
Toot
s down to just the retoots.
Parameters:
Name | Type | Description |
---|---|---|
toots |
Array.<module:api/objects/toot~Toot> | Array of toots. |
Returns:
Array of retoots.
- Type
- Array.<module:api/objects/toot~Toot>
(async, static) removeInvalidToots(toots, logger) → {Promise.<Array.<module:api/objects/toot~Toot>>}
Get rid of
Toot
s we never want to see again.
Parameters:
Name | Type | Description |
---|---|---|
toots |
Array.<module:api/objects/toot~Toot> | Array of toots. |
logger |
Logger | Logger for logging. |
Returns:
- Type
- Promise.<Array.<module:api/objects/toot~Toot>>
(static) removeUsersOwnToots(toots, logger) → {Array.<module:api/objects/toot~Toot>}
Get rid of the user's own
Toot
s.
Parameters:
Name | Type | Description |
---|---|---|
toots |
Array.<module:api/objects/toot~Toot> | Array of toots. |
logger |
Logger | Logger for logging. |
Returns:
Array without user's own toots.
- Type
- Array.<module:api/objects/toot~Toot>