@atproto/api 0.6.2 → 0.6.3

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.
@@ -7,6 +7,7 @@ export declare class ModerationCauseAccumulator {
7
7
  setDid(did: string): void;
8
8
  addBlocking(blocking: string | undefined): void;
9
9
  addBlockedBy(blockedBy: boolean | undefined): void;
10
+ addBlockOther(blockOther: boolean | undefined): void;
10
11
  addLabel(label: Label, opts: ModerationOpts): void;
11
12
  addMuted(muted: boolean | undefined): void;
12
13
  addMutedByList(mutedByList: AppBskyGraphDefs.ListViewBasic | undefined): void;
@@ -61,6 +61,10 @@ export declare type ModerationCause = {
61
61
  type: 'blocked-by';
62
62
  source: ModerationCauseSource;
63
63
  priority: 4;
64
+ } | {
65
+ type: 'block-other';
66
+ source: ModerationCauseSource;
67
+ priority: 4;
64
68
  } | {
65
69
  type: 'label';
66
70
  source: ModerationCauseSource;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "yarn docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -4283,22 +4283,34 @@ export const schemaDict = {
4283
4283
  },
4284
4284
  viewNotFound: {
4285
4285
  type: 'object',
4286
- required: ['uri'],
4286
+ required: ['uri', 'notFound'],
4287
4287
  properties: {
4288
4288
  uri: {
4289
4289
  type: 'string',
4290
4290
  format: 'at-uri',
4291
4291
  },
4292
+ notFound: {
4293
+ type: 'boolean',
4294
+ const: true,
4295
+ },
4292
4296
  },
4293
4297
  },
4294
4298
  viewBlocked: {
4295
4299
  type: 'object',
4296
- required: ['uri'],
4300
+ required: ['uri', 'blocked', 'author'],
4297
4301
  properties: {
4298
4302
  uri: {
4299
4303
  type: 'string',
4300
4304
  format: 'at-uri',
4301
4305
  },
4306
+ blocked: {
4307
+ type: 'boolean',
4308
+ const: true,
4309
+ },
4310
+ author: {
4311
+ type: 'ref',
4312
+ ref: 'lex:app.bsky.feed.defs#blockedAuthor',
4313
+ },
4302
4314
  },
4303
4315
  },
4304
4316
  },
@@ -84,6 +84,7 @@ export function validateViewRecord(v: unknown): ValidationResult {
84
84
 
85
85
  export interface ViewNotFound {
86
86
  uri: string
87
+ notFound: true
87
88
  [k: string]: unknown
88
89
  }
89
90
 
@@ -101,6 +102,8 @@ export function validateViewNotFound(v: unknown): ValidationResult {
101
102
 
102
103
  export interface ViewBlocked {
103
104
  uri: string
105
+ blocked: true
106
+ author: AppBskyFeedDefs.BlockedAuthor
104
107
  [k: string]: unknown
105
108
  }
106
109
 
@@ -38,6 +38,16 @@ export class ModerationCauseAccumulator {
38
38
  }
39
39
  }
40
40
 
41
+ addBlockOther(blockOther: boolean | undefined) {
42
+ if (blockOther) {
43
+ this.causes.push({
44
+ type: 'block-other',
45
+ source: { type: 'user' },
46
+ priority: 4,
47
+ })
48
+ }
49
+ }
50
+
41
51
  addLabel(label: Label, opts: ModerationOpts) {
42
52
  // look up the label definition
43
53
  const labelDef = LABELS[label.val]
@@ -134,7 +144,11 @@ export class ModerationCauseAccumulator {
134
144
  mod.additionalCauses = this.causes.slice(1)
135
145
 
136
146
  // blocked user
137
- if (mod.cause.type === 'blocking' || mod.cause.type === 'blocked-by') {
147
+ if (
148
+ mod.cause.type === 'blocking' ||
149
+ mod.cause.type === 'blocked-by' ||
150
+ mod.cause.type === 'block-other'
151
+ ) {
138
152
  // filter and blur, dont allow override
139
153
  mod.filter = true
140
154
  mod.blur = true
@@ -17,6 +17,15 @@ export function decideQuotedPost(
17
17
  acc.addLabel(label, opts)
18
18
  }
19
19
  }
20
+ } else if (AppBskyEmbedRecord.isViewBlocked(subject.record)) {
21
+ acc.setDid(subject.record.author.did)
22
+ if (subject.record.author.viewer?.blocking) {
23
+ acc.addBlocking(subject.record.author.viewer?.blocking)
24
+ } else if (subject.record.author.viewer?.blockedBy) {
25
+ acc.addBlockedBy(subject.record.author.viewer?.blockedBy)
26
+ } else {
27
+ acc.addBlockOther(true)
28
+ }
20
29
  }
21
30
 
22
31
  return acc.finalizeDecision(opts)
@@ -46,6 +55,15 @@ export function decideQuotedPostWithMedia(
46
55
  acc.addLabel(label, opts)
47
56
  }
48
57
  }
58
+ } else if (AppBskyEmbedRecord.isViewBlocked(subject.record.record)) {
59
+ acc.setDid(subject.record.record.author.did)
60
+ if (subject.record.record.author.viewer?.blocking) {
61
+ acc.addBlocking(subject.record.record.author.viewer?.blocking)
62
+ } else if (subject.record.record.author.viewer?.blockedBy) {
63
+ acc.addBlockedBy(subject.record.record.author.viewer?.blockedBy)
64
+ } else {
65
+ acc.addBlockOther(true)
66
+ }
49
67
  }
50
68
 
51
69
  return acc.finalizeDecision(opts)
@@ -100,6 +100,7 @@ export type ModerationCauseSource =
100
100
  export type ModerationCause =
101
101
  | { type: 'blocking'; source: ModerationCauseSource; priority: 3 }
102
102
  | { type: 'blocked-by'; source: ModerationCauseSource; priority: 4 }
103
+ | { type: 'block-other'; source: ModerationCauseSource; priority: 4 }
103
104
  | {
104
105
  type: 'label'
105
106
  source: ModerationCauseSource
@@ -70,25 +70,13 @@ export function isModerationDecisionNoop(
70
70
  }
71
71
 
72
72
  export function isQuotedPost(embed: unknown): embed is AppBskyEmbedRecord.View {
73
- return Boolean(
74
- embed &&
75
- AppBskyEmbedRecord.isView(embed) &&
76
- AppBskyEmbedRecord.isViewRecord(embed.record) &&
77
- AppBskyFeedPost.isRecord(embed.record.value) &&
78
- AppBskyFeedPost.validateRecord(embed.record.value).success,
79
- )
73
+ return Boolean(embed && AppBskyEmbedRecord.isView(embed))
80
74
  }
81
75
 
82
76
  export function isQuotedPostWithMedia(
83
77
  embed: unknown,
84
78
  ): embed is AppBskyEmbedRecordWithMedia.View {
85
- return Boolean(
86
- embed &&
87
- AppBskyEmbedRecordWithMedia.isView(embed) &&
88
- AppBskyEmbedRecord.isViewRecord(embed.record.record) &&
89
- AppBskyFeedPost.isRecord(embed.record.record.value) &&
90
- AppBskyFeedPost.validateRecord(embed.record.record.value).success,
91
- )
79
+ return Boolean(embed && AppBskyEmbedRecordWithMedia.isView(embed))
92
80
  }
93
81
 
94
82
  export function toModerationUI(decision: ModerationDecision): ModerationUI {