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
import Foundation
struct MediaMappingFixture {
var author: [String: Any] {
["did": "did:plc:media", "handle": "media.example"]
}
func post(_ id: String, text: String = "", embed: [String: Any] = [:]) -> [String: Any] {
[
"uri": "at://did:plc:media/app.bsky.feed.post/\(id)",
"cid": "cid-\(id)",
"author": author,
"record": ["text": text, "createdAt": "2024-05-06T12:34:56.123Z"],
"indexedAt": "2024-05-06T12:34:56.123Z",
"embed": embed
]
}
var attachedImage: [String: Any] {
post(
"attached-image",
embed: [
"$type": "app.bsky.embed.images#view",
"images": [
[
"thumb": "https://cdn.example.test/photo-thumb.jpg",
"fullsize": "https://cdn.example.test/photo.jpg", "alt": "Photo"
]
]
])
}
var attachedVideo: [String: Any] {
post(
"attached-video",
embed: [
"$type": "app.bsky.embed.video#view",
"cid": "video-cid",
"playlist": "https://video.example.test/playlist.m3u8"
])
}
var attachedGIFVideo: [String: Any] {
post(
"attached-gif-video",
embed: [
"$type": "app.bsky.embed.video#view",
"cid": "animated-cid",
"playlist": "https://video.example.test/animated.m3u8",
"presentation": "gif"
])
}
var quotedURI: String {
"at://did:plc:quoted/app.bsky.feed.post/original"
}
var quotedText: String {
"🌙 https://quoted.example @quoted.example #quote"
}
var quotedLinkRange: (Int, Int) { byteRange(of: "https://quoted.example", in: quotedText) }
var quotedLinkStart: Int { quotedLinkRange.0 }
var quotedLinkEnd: Int { quotedLinkRange.1 }
var quotedMentionRange: (Int, Int) { byteRange(of: "@quoted.example", in: quotedText) }
var quotedMentionStart: Int { quotedMentionRange.0 }
var quotedMentionEnd: Int { quotedMentionRange.1 }
var quotedTagRange: (Int, Int) { byteRange(of: "#quote", in: quotedText) }
var quotedTagStart: Int { quotedTagRange.0 }
var quotedTagEnd: Int { quotedTagRange.1 }
}