1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import {
AppBskyActorDefs,
AppBskyFeedDefs,
AppBskyFeedPost,
AppBskyGraphDefs,
} from '@atproto/api'
import {
type ParsedReportSubject,
type ReportSubject,
} from '#/components/moderation/ReportDialog/types'
import * as bsky from '#/types/bsky'
export function parseReportSubject(
subject: ReportSubject,
): ParsedReportSubject | undefined {
if (!subject) return
if ('convoId' in subject) {
return {
type: 'chatMessage',
...subject,
}
}
if (
AppBskyActorDefs.isProfileViewBasic(subject) ||
AppBskyActorDefs.isProfileView(subject) ||
AppBskyActorDefs.isProfileViewDetailed(subject)
) {
return {
type: 'account',
did: subject.did,
nsid: 'app.bsky.actor.profile',
}
} else if (AppBskyGraphDefs.isListView(subject)) {
return {
type: 'list',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.graph.list',
}
} else if (AppBskyFeedDefs.isGeneratorView(subject)) {
return {
type: 'feed',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.feed.generator',
}
} else if (AppBskyGraphDefs.isStarterPackView(subject)) {
return {
type: 'starterPack',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.graph.starterPack',
}
} else if (AppBskyFeedDefs.isPostView(subject)) {
const record = subject.record
const embed = bsky.post.parseEmbed(subject.embed)
if (
bsky.dangerousIsType<AppBskyFeedPost.Record>(
record,
AppBskyFeedPost.isRecord,
)
) {
return {
type: 'post',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.feed.post',
attributes: {
reply: !!record.reply,
image:
embed.type === 'images' ||
(embed.type === 'post_with_media' && embed.media.type === 'images'),
video:
embed.type === 'video' ||
(embed.type === 'post_with_media' && embed.media.type === 'video'),
link:
embed.type === 'link' ||
(embed.type === 'post_with_media' && embed.media.type === 'link'),
quote:
embed.type === 'post' ||
(embed.type === 'post_with_media' &&
(embed.view.type === 'post' ||
embed.view.type === 'post_with_media')),
},
}
}
}
}
|