Skip to content

Commit ca768fe

Browse files
authored
🐛 Fix query for ozone subject status with blobs (#4274)
* 🐛 Fix query for ozone subject status with blobs * 📝 Add changeset
1 parent 386f583 commit ca768fe

File tree

4 files changed

+207
-1
lines changed

4 files changed

+207
-1
lines changed

.changeset/cold-tigers-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@atproto/ozone": patch
3+
---
4+
5+
Fix fetching event detail for subject with blob

packages/ozone/src/mod-service/views.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ export class ModerationViews {
578578
'moderation_subject_status.blobCids',
579579
)} @> ${JSON.stringify(blobs.map((blob) => blob.ref.toString()))}`,
580580
)
581-
.selectAll()
582581
.executeTakeFirst()
582+
583583
const statusByCid = (modStatusResults?.blobCids || [])?.reduce(
584584
(acc, cur) => Object.assign(acc, { [cur]: modStatusResults }),
585585
{},
@@ -592,6 +592,7 @@ export class ModerationViews {
592592
const subjectStatus = statusByCid[cid]
593593
? this.formatSubjectStatus(statusByCid[cid])
594594
: undefined
595+
595596
return {
596597
cid,
597598
mimeType: blob.mimeType,

packages/ozone/tests/__snapshots__/blob-divert.test.ts.snap

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,200 @@ Object {
2020
],
2121
}
2222
`;
23+
24+
exports[`blob divert sends blobs to configured divert service and marks divert date 2`] = `
25+
Object {
26+
"createdAt": "1970-01-01T00:00:00.000Z",
27+
"createdBy": "user(1)",
28+
"event": Object {
29+
"$type": "tools.ozone.moderation.defs#modEventDivert",
30+
"comment": "Diverting for test",
31+
},
32+
"id": 1,
33+
"subject": Object {
34+
"$type": "tools.ozone.moderation.defs#recordView",
35+
"blobCids": Array [
36+
"cids(1)",
37+
"cids(2)",
38+
],
39+
"cid": "cids(0)",
40+
"indexedAt": "1970-01-01T00:00:00.000Z",
41+
"moderation": Object {
42+
"subjectStatus": Object {
43+
"accountStats": Object {
44+
"$type": "tools.ozone.moderation.defs#accountStats",
45+
},
46+
"ageAssuranceState": "unknown",
47+
"createdAt": "1970-01-01T00:00:00.000Z",
48+
"hosting": Object {
49+
"$type": "tools.ozone.moderation.defs#recordHosting",
50+
"status": "unknown",
51+
},
52+
"id": 1,
53+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
54+
"lastReviewedBy": "user(1)",
55+
"priorityScore": 0,
56+
"recordsStats": Object {
57+
"$type": "tools.ozone.moderation.defs#recordsStats",
58+
},
59+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
60+
"subject": Object {
61+
"$type": "com.atproto.repo.strongRef",
62+
"cid": "cids(0)",
63+
"uri": "record(0)",
64+
},
65+
"subjectBlobCids": Array [
66+
"cids(1)",
67+
"cids(2)",
68+
],
69+
"subjectRepoHandle": "carol.test",
70+
"tags": Array [
71+
"lang:it",
72+
"embed:image",
73+
],
74+
"takendown": true,
75+
"updatedAt": "1970-01-01T00:00:00.000Z",
76+
},
77+
},
78+
"repo": Object {
79+
"did": "user(0)",
80+
"handle": "carol.test",
81+
"indexedAt": "1970-01-01T00:00:00.000Z",
82+
"moderation": Object {},
83+
"relatedRecords": Array [],
84+
},
85+
"uri": "record(0)",
86+
"value": Object {
87+
"$type": "app.bsky.feed.post",
88+
"createdAt": "1970-01-01T00:00:00.000Z",
89+
"embed": Object {
90+
"$type": "app.bsky.embed.recordWithMedia",
91+
"media": Object {
92+
"$type": "app.bsky.embed.images",
93+
"images": Array [
94+
Object {
95+
"alt": "../dev-env/assets/key-landscape-small.jpg",
96+
"image": Object {
97+
"$type": "blob",
98+
"mimeType": "image/jpeg",
99+
"ref": Object {
100+
"$link": "cids(1)",
101+
},
102+
"size": 4114,
103+
},
104+
},
105+
Object {
106+
"alt": "../dev-env/assets/key-alt.jpg",
107+
"image": Object {
108+
"$type": "blob",
109+
"mimeType": "image/jpeg",
110+
"ref": Object {
111+
"$link": "cids(2)",
112+
},
113+
"size": 12736,
114+
},
115+
},
116+
],
117+
},
118+
"record": Object {
119+
"record": Object {
120+
"cid": "cids(3)",
121+
"uri": "record(1)",
122+
},
123+
},
124+
},
125+
"text": "hi im carol",
126+
},
127+
},
128+
"subjectBlobCids": Array [
129+
"cids(1)",
130+
"cids(2)",
131+
],
132+
"subjectBlobs": Array [
133+
Object {
134+
"cid": "cids(1)",
135+
"createdAt": "1970-01-01T00:00:00.000Z",
136+
"mimeType": "image/jpeg",
137+
"moderation": Object {
138+
"subjectStatus": Object {
139+
"accountStats": Object {
140+
"$type": "tools.ozone.moderation.defs#accountStats",
141+
},
142+
"ageAssuranceState": "unknown",
143+
"createdAt": "1970-01-01T00:00:00.000Z",
144+
"hosting": Object {
145+
"$type": "tools.ozone.moderation.defs#recordHosting",
146+
"status": "unknown",
147+
},
148+
"id": 1,
149+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
150+
"lastReviewedBy": "user(1)",
151+
"priorityScore": 0,
152+
"recordsStats": Object {
153+
"$type": "tools.ozone.moderation.defs#recordsStats",
154+
},
155+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
156+
"subject": Object {
157+
"$type": "com.atproto.repo.strongRef",
158+
"cid": "cids(0)",
159+
"uri": "record(0)",
160+
},
161+
"subjectBlobCids": Array [
162+
"cids(1)",
163+
"cids(2)",
164+
],
165+
"tags": Array [
166+
"lang:it",
167+
"embed:image",
168+
],
169+
"takendown": true,
170+
"updatedAt": "1970-01-01T00:00:00.000Z",
171+
},
172+
},
173+
"size": 4114,
174+
},
175+
Object {
176+
"cid": "cids(2)",
177+
"createdAt": "1970-01-01T00:00:00.000Z",
178+
"mimeType": "image/jpeg",
179+
"moderation": Object {
180+
"subjectStatus": Object {
181+
"accountStats": Object {
182+
"$type": "tools.ozone.moderation.defs#accountStats",
183+
},
184+
"ageAssuranceState": "unknown",
185+
"createdAt": "1970-01-01T00:00:00.000Z",
186+
"hosting": Object {
187+
"$type": "tools.ozone.moderation.defs#recordHosting",
188+
"status": "unknown",
189+
},
190+
"id": 1,
191+
"lastReviewedAt": "1970-01-01T00:00:00.000Z",
192+
"lastReviewedBy": "user(1)",
193+
"priorityScore": 0,
194+
"recordsStats": Object {
195+
"$type": "tools.ozone.moderation.defs#recordsStats",
196+
},
197+
"reviewState": "tools.ozone.moderation.defs#reviewClosed",
198+
"subject": Object {
199+
"$type": "com.atproto.repo.strongRef",
200+
"cid": "cids(0)",
201+
"uri": "record(0)",
202+
},
203+
"subjectBlobCids": Array [
204+
"cids(1)",
205+
"cids(2)",
206+
],
207+
"tags": Array [
208+
"lang:it",
209+
"embed:image",
210+
],
211+
"takendown": true,
212+
"updatedAt": "1970-01-01T00:00:00.000Z",
213+
},
214+
},
215+
"size": 12736,
216+
},
217+
],
218+
}
219+
`;

packages/ozone/tests/blob-divert.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ describe('blob divert', () => {
9595
})
9696

9797
expect(subjectStatuses[0].takendown).toBe(true)
98+
99+
const event = await modClient.getEvent(divertEvent.id)
100+
expect(forSnapshot(event)).toMatchSnapshot()
98101
} finally {
99102
reportServiceRequest.mockRestore()
100103
}

0 commit comments

Comments
 (0)