~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
73 lines · 2.3 KB Raw History
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 }
}