@atproto/api 0.15.14 → 0.15.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/client/lexicons.d.ts +8 -8
- package/dist/client/lexicons.js +4 -4
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/notification/defs.d.ts +2 -2
- package/dist/client/types/app/bsky/notification/defs.d.ts.map +1 -1
- package/dist/moderation/decision.d.ts +2 -1
- package/dist/moderation/decision.d.ts.map +1 -1
- package/dist/moderation/decision.js +3 -2
- package/dist/moderation/decision.js.map +1 -1
- package/dist/moderation/index.d.ts +1 -1
- package/dist/moderation/index.d.ts.map +1 -1
- package/dist/moderation/index.js +2 -1
- package/dist/moderation/index.js.map +1 -1
- package/dist/moderation/mutewords.d.ts +22 -2
- package/dist/moderation/mutewords.d.ts.map +1 -1
- package/dist/moderation/mutewords.js +63 -25
- package/dist/moderation/mutewords.js.map +1 -1
- package/dist/moderation/subjects/post.js +49 -39
- package/dist/moderation/subjects/post.js.map +1 -1
- package/dist/moderation/types.d.ts +2 -0
- package/dist/moderation/types.d.ts.map +1 -1
- package/dist/moderation/types.js.map +1 -1
- package/package.json +1 -1
- package/src/client/lexicons.ts +4 -4
- package/src/client/types/app/bsky/notification/defs.ts +2 -2
- package/src/moderation/decision.ts +4 -2
- package/src/moderation/index.ts +1 -1
- package/src/moderation/mutewords.ts +88 -26
- package/src/moderation/subjects/post.ts +104 -115
- package/src/moderation/types.ts +2 -0
- package/tests/moderation-mutewords.test.ts +153 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/moderation/subjects/post.ts"],"names":[],"mappings":";;AAeA,gCAUC;AAzBD,yCAOqB;AAErB,0CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/moderation/subjects/post.ts"],"names":[],"mappings":";;AAeA,gCAUC;AA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ACnB,CAAC,CAAA;gBACF,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,OAAO,CAAA;gBAChB,CAAC;YACH,CAAC;YAED,qBAAqB;YACrB,IAAI,2BAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3C,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;oBACvC,MAAM,OAAO,GAAG,IAAA,0BAAc,EAAC;wBAC7B,UAAU;wBACV,IAAI,EAAE,KAAK,CAAC,GAAG;wBACf,SAAS,EAAE,wBAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;4BACjD,CAAC,CAAE,OAAO,CAAC,MAAiC,CAAC,KAAK;4BAClD,CAAC,CAAC,EAAE;wBACN,KAAK,EAAE,WAAW;qBACnB,CAAC,CAAA;oBACF,IAAI,OAAO,EAAE,CAAC;wBACZ,OAAO,OAAO,CAAA;oBAChB,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,6BAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7C,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,KAAK,CAAA;gBAChC,MAAM,OAAO,GAAG,IAAA,0BAAc,EAAC;oBAC7B,UAAU;oBACV,IAAI,EAAE,QAAQ,CAAC,KAAK,GAAG,GAAG,GAAG,QAAQ,CAAC,WAAW;oBACjD,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,WAAW;iBACnB,CAAC,CAAA;gBACF,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,OAAO,CAAA;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppBskyActorDefs, AppBskyFeedDefs, AppBskyGraphDefs, AppBskyNotificationListNotifications, ChatBskyActorDefs, ComAtprotoLabelDefs } from '../client/index';
|
|
2
2
|
import { KnownLabelValue } from './const/labels';
|
|
3
|
+
import { MuteWordMatch } from './mutewords';
|
|
3
4
|
export declare const CUSTOM_LABEL_VALUE_RE: RegExp;
|
|
4
5
|
export interface ModerationBehavior {
|
|
5
6
|
profileList?: 'blur' | 'alert' | 'inform';
|
|
@@ -83,6 +84,7 @@ export type ModerationCause = {
|
|
|
83
84
|
source: ModerationCauseSource;
|
|
84
85
|
priority: 6;
|
|
85
86
|
downgraded?: boolean;
|
|
87
|
+
matches: MuteWordMatch[];
|
|
86
88
|
} | {
|
|
87
89
|
type: 'hidden';
|
|
88
90
|
source: ModerationCauseSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/moderation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,oCAAoC,EACpC,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/moderation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,oCAAoC,EACpC,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAK3C,eAAO,MAAM,qBAAqB,QAAc,CAAA;AAKhD,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAA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+B,EAAE,CAAC,CAAA;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/moderation/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/moderation/types.ts"],"names":[],"mappings":";;;AAWA,SAAS;AACT,IAAI;AAES,QAAA,qBAAqB,GAAG,WAAW,CAAA;AAenC,QAAA,cAAc,GAAuB;IAChD,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;CACpB,CAAA;AACY,QAAA,aAAa,GAAuB;IAC/C,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,QAAQ;CACtB,CAAA;AACY,QAAA,iBAAiB,GAAuB;IACnD,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;CACpB,CAAA;AACY,QAAA,aAAa,GAAuB;IAC/C,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;CACpB,CAAA;AACY,QAAA,aAAa,GAAuB,EAAE,CAAA"}
|
package/package.json
CHANGED
package/src/client/lexicons.ts
CHANGED
|
@@ -9734,9 +9734,9 @@ export const schemaDict = {
|
|
|
9734
9734
|
},
|
|
9735
9735
|
chatPreference: {
|
|
9736
9736
|
type: 'object',
|
|
9737
|
-
required: ['
|
|
9737
|
+
required: ['include', 'push'],
|
|
9738
9738
|
properties: {
|
|
9739
|
-
|
|
9739
|
+
include: {
|
|
9740
9740
|
type: 'string',
|
|
9741
9741
|
knownValues: ['all', 'accepted'],
|
|
9742
9742
|
},
|
|
@@ -9747,9 +9747,9 @@ export const schemaDict = {
|
|
|
9747
9747
|
},
|
|
9748
9748
|
filterablePreference: {
|
|
9749
9749
|
type: 'object',
|
|
9750
|
-
required: ['
|
|
9750
|
+
required: ['include', 'list', 'push'],
|
|
9751
9751
|
properties: {
|
|
9752
|
-
|
|
9752
|
+
include: {
|
|
9753
9753
|
type: 'string',
|
|
9754
9754
|
knownValues: ['all', 'follows'],
|
|
9755
9755
|
},
|
|
@@ -30,7 +30,7 @@ export function validateRecordDeleted<V>(v: V) {
|
|
|
30
30
|
|
|
31
31
|
export interface ChatPreference {
|
|
32
32
|
$type?: 'app.bsky.notification.defs#chatPreference'
|
|
33
|
-
|
|
33
|
+
include: 'all' | 'accepted' | (string & {})
|
|
34
34
|
push: boolean
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -46,7 +46,7 @@ export function validateChatPreference<V>(v: V) {
|
|
|
46
46
|
|
|
47
47
|
export interface FilterablePreference {
|
|
48
48
|
$type?: 'app.bsky.notification.defs#filterablePreference'
|
|
49
|
-
|
|
49
|
+
include: 'all' | 'follows' | (string & {})
|
|
50
50
|
list: boolean
|
|
51
51
|
push: boolean
|
|
52
52
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppBskyGraphDefs } from '../client/index'
|
|
2
2
|
import { LABELS } from './const/labels'
|
|
3
|
+
import { MuteWordMatch } from './mutewords'
|
|
3
4
|
import {
|
|
4
5
|
BLOCK_BEHAVIOR,
|
|
5
6
|
CUSTOM_LABEL_VALUE_RE,
|
|
@@ -195,12 +196,13 @@ export class ModerationDecision {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
addMutedWord(
|
|
199
|
-
if (
|
|
199
|
+
addMutedWord(matches: MuteWordMatch[] | undefined) {
|
|
200
|
+
if (matches?.length) {
|
|
200
201
|
this.causes.push({
|
|
201
202
|
type: 'mute-word',
|
|
202
203
|
source: { type: 'user' },
|
|
203
204
|
priority: 6,
|
|
205
|
+
matches,
|
|
204
206
|
})
|
|
205
207
|
}
|
|
206
208
|
}
|
package/src/moderation/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
|
|
17
17
|
export { ModerationUI } from './ui'
|
|
18
18
|
export { ModerationDecision } from './decision'
|
|
19
|
-
export { hasMutedWord } from './mutewords'
|
|
19
|
+
export { hasMutedWord, matchMuteWords } from './mutewords'
|
|
20
20
|
export {
|
|
21
21
|
interpretLabelValueDefinition,
|
|
22
22
|
interpretLabelValueDefinitions,
|
|
@@ -21,21 +21,38 @@ const LANGUAGE_EXCEPTIONS = [
|
|
|
21
21
|
'vi', // Vietnamese
|
|
22
22
|
]
|
|
23
23
|
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
export type MuteWordMatch = {
|
|
25
|
+
/**
|
|
26
|
+
* The `AppBskyActorDefs.MutedWord` that matched.
|
|
27
|
+
*/
|
|
28
|
+
word: AppBskyActorDefs.MutedWord
|
|
29
|
+
/**
|
|
30
|
+
* The string that matched the muted word.
|
|
31
|
+
*/
|
|
32
|
+
predicate: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type Params = {
|
|
32
36
|
mutedWords: AppBskyActorDefs.MutedWord[]
|
|
33
37
|
text: string
|
|
34
38
|
facets?: AppBskyRichtextFacet.Main[]
|
|
35
39
|
outlineTags?: string[]
|
|
36
40
|
languages?: string[]
|
|
37
41
|
actor?: AppBskyActorDefs.ProfileView | AppBskyActorDefs.ProfileViewBasic
|
|
38
|
-
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Checks if the given text matches any of the muted words, returning an array
|
|
46
|
+
* of matches. If no matches are found, returns `undefined`.
|
|
47
|
+
*/
|
|
48
|
+
export function matchMuteWords({
|
|
49
|
+
mutedWords,
|
|
50
|
+
text,
|
|
51
|
+
facets,
|
|
52
|
+
outlineTags,
|
|
53
|
+
languages,
|
|
54
|
+
actor,
|
|
55
|
+
}: Params): MuteWordMatch[] | undefined {
|
|
39
56
|
const exception = LANGUAGE_EXCEPTIONS.includes(languages?.[0] || '')
|
|
40
57
|
const tags = ([] as string[])
|
|
41
58
|
.concat(outlineTags || [])
|
|
@@ -46,38 +63,54 @@ export function hasMutedWord({
|
|
|
46
63
|
)
|
|
47
64
|
.map((t) => t.toLowerCase())
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
const matches: MuteWordMatch[] = []
|
|
67
|
+
|
|
68
|
+
outer: for (const muteWord of mutedWords) {
|
|
69
|
+
const mutedWord = muteWord.value.toLowerCase()
|
|
51
70
|
const postText = text.toLowerCase()
|
|
52
71
|
|
|
53
72
|
// expired, ignore
|
|
54
|
-
if (
|
|
73
|
+
if (muteWord.expiresAt && muteWord.expiresAt < new Date().toISOString())
|
|
74
|
+
continue
|
|
55
75
|
|
|
56
76
|
if (
|
|
57
|
-
|
|
77
|
+
muteWord.actorTarget === 'exclude-following' &&
|
|
58
78
|
Boolean(actor?.viewer?.following)
|
|
59
79
|
)
|
|
60
80
|
continue
|
|
61
81
|
|
|
62
82
|
// `content` applies to tags as well
|
|
63
|
-
if (tags.includes(mutedWord))
|
|
83
|
+
if (tags.includes(mutedWord)) {
|
|
84
|
+
matches.push({ word: muteWord, predicate: muteWord.value })
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
64
87
|
// rest of the checks are for `content` only
|
|
65
|
-
if (!
|
|
88
|
+
if (!muteWord.targets.includes('content')) continue
|
|
66
89
|
// single character or other exception, has to use includes
|
|
67
|
-
if ((mutedWord.length === 1 || exception) && postText.includes(mutedWord))
|
|
68
|
-
|
|
90
|
+
if ((mutedWord.length === 1 || exception) && postText.includes(mutedWord)) {
|
|
91
|
+
matches.push({ word: muteWord, predicate: muteWord.value })
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
69
94
|
// too long
|
|
70
95
|
if (mutedWord.length > postText.length) continue
|
|
71
96
|
// exact match
|
|
72
|
-
if (mutedWord === postText)
|
|
97
|
+
if (mutedWord === postText) {
|
|
98
|
+
matches.push({ word: muteWord, predicate: muteWord.value })
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
73
101
|
// any muted phrase with space or punctuation
|
|
74
|
-
if (/(?:\s|\p{P})+?/u.test(mutedWord) && postText.includes(mutedWord))
|
|
75
|
-
|
|
102
|
+
if (/(?:\s|\p{P})+?/u.test(mutedWord) && postText.includes(mutedWord)) {
|
|
103
|
+
matches.push({ word: muteWord, predicate: muteWord.value })
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
76
106
|
|
|
77
107
|
// check individual character groups
|
|
78
108
|
const words = postText.split(REGEX.WORD_BOUNDARY)
|
|
79
109
|
for (const word of words) {
|
|
80
|
-
if (word === mutedWord)
|
|
110
|
+
if (word === mutedWord) {
|
|
111
|
+
matches.push({ word: muteWord, predicate: word })
|
|
112
|
+
continue outer
|
|
113
|
+
}
|
|
81
114
|
|
|
82
115
|
// compare word without leading/trailing punctuation, but allow internal
|
|
83
116
|
// punctuation (such as `s@ssy`)
|
|
@@ -86,23 +119,52 @@ export function hasMutedWord({
|
|
|
86
119
|
'',
|
|
87
120
|
)
|
|
88
121
|
|
|
89
|
-
if (mutedWord === wordTrimmedPunctuation)
|
|
122
|
+
if (mutedWord === wordTrimmedPunctuation) {
|
|
123
|
+
matches.push({ word: muteWord, predicate: word })
|
|
124
|
+
continue outer
|
|
125
|
+
}
|
|
126
|
+
|
|
90
127
|
if (mutedWord.length > wordTrimmedPunctuation.length) continue
|
|
91
128
|
|
|
92
129
|
if (/\p{P}+/u.test(wordTrimmedPunctuation)) {
|
|
130
|
+
/**
|
|
131
|
+
* Exit case for any punctuation within the predicate that we _do_
|
|
132
|
+
* allow e.g. `and/or` should not match `Andor`.
|
|
133
|
+
*/
|
|
134
|
+
if (/[/]+/.test(wordTrimmedPunctuation)) {
|
|
135
|
+
continue outer
|
|
136
|
+
}
|
|
137
|
+
|
|
93
138
|
const spacedWord = wordTrimmedPunctuation.replace(/\p{P}+/gu, ' ')
|
|
94
|
-
if (spacedWord === mutedWord)
|
|
139
|
+
if (spacedWord === mutedWord) {
|
|
140
|
+
matches.push({ word: muteWord, predicate: word })
|
|
141
|
+
continue outer
|
|
142
|
+
}
|
|
95
143
|
|
|
96
144
|
const contiguousWord = spacedWord.replace(/\s/gu, '')
|
|
97
|
-
if (contiguousWord === mutedWord)
|
|
145
|
+
if (contiguousWord === mutedWord) {
|
|
146
|
+
matches.push({ word: muteWord, predicate: word })
|
|
147
|
+
continue outer
|
|
148
|
+
}
|
|
98
149
|
|
|
99
150
|
const wordParts = wordTrimmedPunctuation.split(/\p{P}+/u)
|
|
100
151
|
for (const wordPart of wordParts) {
|
|
101
|
-
if (wordPart === mutedWord)
|
|
152
|
+
if (wordPart === mutedWord) {
|
|
153
|
+
matches.push({ word: muteWord, predicate: word })
|
|
154
|
+
continue outer
|
|
155
|
+
}
|
|
102
156
|
}
|
|
103
157
|
}
|
|
104
158
|
}
|
|
105
159
|
}
|
|
106
160
|
|
|
107
|
-
return
|
|
161
|
+
return matches.length ? matches : undefined
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Checks if the given text matches any of the muted words, returning a boolean
|
|
166
|
+
* if any matches are found.
|
|
167
|
+
*/
|
|
168
|
+
export function hasMutedWord(params: Params) {
|
|
169
|
+
return !!matchMuteWords(params)
|
|
108
170
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../../client'
|
|
9
9
|
import { $Typed } from '../../client/util'
|
|
10
10
|
import { ModerationDecision } from '../decision'
|
|
11
|
-
import {
|
|
11
|
+
import { MuteWordMatch, matchMuteWords } from '../mutewords'
|
|
12
12
|
import { ModerationOpts, ModerationSubjectPost } from '../types'
|
|
13
13
|
import { decideAccount } from './account'
|
|
14
14
|
import { decideProfile } from './profile'
|
|
@@ -40,7 +40,7 @@ function decideSubject(
|
|
|
40
40
|
}
|
|
41
41
|
acc.addHidden(checkHiddenPost(subject, opts.prefs.hiddenPosts))
|
|
42
42
|
if (!acc.isMe) {
|
|
43
|
-
acc.addMutedWord(
|
|
43
|
+
acc.addMutedWord(matchAllMuteWords(subject, opts.prefs.mutedWords))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return acc
|
|
@@ -160,44 +160,43 @@ function checkHiddenPost(
|
|
|
160
160
|
return false
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
function
|
|
163
|
+
function matchAllMuteWords(
|
|
164
164
|
subject: ModerationSubjectPost,
|
|
165
165
|
mutedWords: AppBskyActorDefs.MutedWord[] | undefined,
|
|
166
|
-
) {
|
|
166
|
+
): MuteWordMatch[] | undefined {
|
|
167
167
|
if (!mutedWords?.length) {
|
|
168
|
-
return
|
|
168
|
+
return
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
const postAuthor = subject.author
|
|
172
172
|
|
|
173
173
|
if (AppBskyFeedPost.isRecord(subject.record)) {
|
|
174
174
|
const post = subject.record as AppBskyFeedPost.Record
|
|
175
|
+
|
|
176
|
+
const matches = matchMuteWords({
|
|
177
|
+
mutedWords,
|
|
178
|
+
text: post.text,
|
|
179
|
+
facets: post.facets,
|
|
180
|
+
outlineTags: post.tags,
|
|
181
|
+
languages: post.langs,
|
|
182
|
+
actor: postAuthor,
|
|
183
|
+
})
|
|
175
184
|
// post text
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
mutedWords,
|
|
179
|
-
text: post.text,
|
|
180
|
-
facets: post.facets,
|
|
181
|
-
outlineTags: post.tags,
|
|
182
|
-
languages: post.langs,
|
|
183
|
-
actor: postAuthor,
|
|
184
|
-
})
|
|
185
|
-
) {
|
|
186
|
-
return true
|
|
185
|
+
if (matches) {
|
|
186
|
+
return matches
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
if (post.embed && AppBskyEmbedImages.isMain(post.embed)) {
|
|
190
190
|
// post images
|
|
191
191
|
for (const image of post.embed.images) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return true
|
|
192
|
+
const matches = matchMuteWords({
|
|
193
|
+
mutedWords,
|
|
194
|
+
text: image.alt,
|
|
195
|
+
languages: post.langs,
|
|
196
|
+
actor: postAuthor,
|
|
197
|
+
})
|
|
198
|
+
if (matches) {
|
|
199
|
+
return matches
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
}
|
|
@@ -214,33 +213,31 @@ function checkMutedWords(
|
|
|
214
213
|
if (AppBskyFeedPost.isRecord(embed.record.value)) {
|
|
215
214
|
const embeddedPost = embed.record.value as AppBskyFeedPost.Record
|
|
216
215
|
const embedAuthor = embed.record.author
|
|
216
|
+
const matches = matchMuteWords({
|
|
217
|
+
mutedWords,
|
|
218
|
+
text: embeddedPost.text,
|
|
219
|
+
facets: embeddedPost.facets,
|
|
220
|
+
outlineTags: embeddedPost.tags,
|
|
221
|
+
languages: embeddedPost.langs,
|
|
222
|
+
actor: embedAuthor,
|
|
223
|
+
})
|
|
217
224
|
|
|
218
225
|
// quoted post text
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
mutedWords,
|
|
222
|
-
text: embeddedPost.text,
|
|
223
|
-
facets: embeddedPost.facets,
|
|
224
|
-
outlineTags: embeddedPost.tags,
|
|
225
|
-
languages: embeddedPost.langs,
|
|
226
|
-
actor: embedAuthor,
|
|
227
|
-
})
|
|
228
|
-
) {
|
|
229
|
-
return true
|
|
226
|
+
if (matches) {
|
|
227
|
+
return matches
|
|
230
228
|
}
|
|
231
229
|
|
|
232
230
|
// quoted post's images
|
|
233
231
|
if (AppBskyEmbedImages.isMain(embeddedPost.embed)) {
|
|
234
232
|
for (const image of embeddedPost.embed.images) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return true
|
|
233
|
+
const matches = matchMuteWords({
|
|
234
|
+
mutedWords,
|
|
235
|
+
text: image.alt,
|
|
236
|
+
languages: embeddedPost.langs,
|
|
237
|
+
actor: embedAuthor,
|
|
238
|
+
})
|
|
239
|
+
if (matches) {
|
|
240
|
+
return matches
|
|
244
241
|
}
|
|
245
242
|
}
|
|
246
243
|
}
|
|
@@ -248,15 +245,14 @@ function checkMutedWords(
|
|
|
248
245
|
// quoted post's link card
|
|
249
246
|
if (AppBskyEmbedExternal.isMain(embeddedPost.embed)) {
|
|
250
247
|
const { external } = embeddedPost.embed
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return true
|
|
248
|
+
const matches = matchMuteWords({
|
|
249
|
+
mutedWords,
|
|
250
|
+
text: external.title + ' ' + external.description,
|
|
251
|
+
languages: [],
|
|
252
|
+
actor: embedAuthor,
|
|
253
|
+
})
|
|
254
|
+
if (matches) {
|
|
255
|
+
return matches
|
|
260
256
|
}
|
|
261
257
|
}
|
|
262
258
|
|
|
@@ -264,32 +260,30 @@ function checkMutedWords(
|
|
|
264
260
|
// quoted post's link card when it did a quote + media
|
|
265
261
|
if (AppBskyEmbedExternal.isMain(embeddedPost.embed.media)) {
|
|
266
262
|
const { external } = embeddedPost.embed.media
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return true
|
|
263
|
+
const matches = matchMuteWords({
|
|
264
|
+
mutedWords,
|
|
265
|
+
text: external.title + ' ' + external.description,
|
|
266
|
+
languages: [],
|
|
267
|
+
actor: embedAuthor,
|
|
268
|
+
})
|
|
269
|
+
if (matches) {
|
|
270
|
+
return matches
|
|
276
271
|
}
|
|
277
272
|
}
|
|
278
273
|
|
|
279
274
|
// quoted post's images when it did a quote + media
|
|
280
275
|
if (AppBskyEmbedImages.isMain(embeddedPost.embed.media)) {
|
|
281
276
|
for (const image of embeddedPost.embed.media.images) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return true
|
|
277
|
+
const matches = matchMuteWords({
|
|
278
|
+
mutedWords,
|
|
279
|
+
text: image.alt,
|
|
280
|
+
languages: AppBskyFeedPost.isRecord(embeddedPost.record)
|
|
281
|
+
? embeddedPost.langs
|
|
282
|
+
: [],
|
|
283
|
+
actor: embedAuthor,
|
|
284
|
+
})
|
|
285
|
+
if (matches) {
|
|
286
|
+
return matches
|
|
293
287
|
}
|
|
294
288
|
}
|
|
295
289
|
}
|
|
@@ -299,15 +293,14 @@ function checkMutedWords(
|
|
|
299
293
|
// link card
|
|
300
294
|
else if (AppBskyEmbedExternal.isView(embed)) {
|
|
301
295
|
const { external } = embed
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return true
|
|
296
|
+
const matches = matchMuteWords({
|
|
297
|
+
mutedWords,
|
|
298
|
+
text: external.title + ' ' + external.description,
|
|
299
|
+
languages: [],
|
|
300
|
+
actor: postAuthor,
|
|
301
|
+
})
|
|
302
|
+
if (matches) {
|
|
303
|
+
return matches
|
|
311
304
|
}
|
|
312
305
|
}
|
|
313
306
|
// quote post with media
|
|
@@ -320,52 +313,48 @@ function checkMutedWords(
|
|
|
320
313
|
// quoted post text
|
|
321
314
|
if (AppBskyFeedPost.isRecord(embed.record.record.value)) {
|
|
322
315
|
const post = embed.record.record.value as AppBskyFeedPost.Record
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return true
|
|
316
|
+
const matches = matchMuteWords({
|
|
317
|
+
mutedWords,
|
|
318
|
+
text: post.text,
|
|
319
|
+
facets: post.facets,
|
|
320
|
+
outlineTags: post.tags,
|
|
321
|
+
languages: post.langs,
|
|
322
|
+
actor: embedAuthor,
|
|
323
|
+
})
|
|
324
|
+
if (matches) {
|
|
325
|
+
return matches
|
|
334
326
|
}
|
|
335
327
|
}
|
|
336
328
|
|
|
337
329
|
// quoted post images
|
|
338
330
|
if (AppBskyEmbedImages.isView(embed.media)) {
|
|
339
331
|
for (const image of embed.media.images) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return true
|
|
332
|
+
const matches = matchMuteWords({
|
|
333
|
+
mutedWords,
|
|
334
|
+
text: image.alt,
|
|
335
|
+
languages: AppBskyFeedPost.isRecord(subject.record)
|
|
336
|
+
? (subject.record as AppBskyFeedPost.Record).langs
|
|
337
|
+
: [],
|
|
338
|
+
actor: embedAuthor,
|
|
339
|
+
})
|
|
340
|
+
if (matches) {
|
|
341
|
+
return matches
|
|
351
342
|
}
|
|
352
343
|
}
|
|
353
344
|
}
|
|
354
345
|
|
|
355
346
|
if (AppBskyEmbedExternal.isView(embed.media)) {
|
|
356
347
|
const { external } = embed.media
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return true
|
|
348
|
+
const matches = matchMuteWords({
|
|
349
|
+
mutedWords,
|
|
350
|
+
text: external.title + ' ' + external.description,
|
|
351
|
+
languages: [],
|
|
352
|
+
actor: embedAuthor,
|
|
353
|
+
})
|
|
354
|
+
if (matches) {
|
|
355
|
+
return matches
|
|
366
356
|
}
|
|
367
357
|
}
|
|
368
358
|
}
|
|
369
359
|
}
|
|
370
|
-
return false
|
|
371
360
|
}
|