Live video on the AT Protocol
1package linking
2
3// import (
4// "context"
5// "net/url"
6// "testing"
7
8// "github.com/bluesky-social/indigo/api/atproto"
9// "github.com/bluesky-social/indigo/api/bsky"
10// lexutil "github.com/bluesky-social/indigo/lex/util"
11// "github.com/stretchr/testify/require"
12// "stream.place/streamplace/pkg/streamplace"
13// )
14
15// func TestNewLinker(t *testing.T) {
16// linker, err := NewLinker(context.Background(), []byte(input))
17// require.NoError(t, err)
18// require.NotNil(t, linker)
19// }
20
21// func TestGenerateLinkCard(t *testing.T) {
22// linker, err := NewLinker(context.Background(), []byte(input))
23// require.NoError(t, err)
24// require.NotNil(t, linker)
25
26// u, err := url.Parse("https://stream.place/iame.li")
27// require.NoError(t, err)
28// sp := "https://stream.place"
29// ls := &streamplace.Livestream{
30// CreatedAt: "2025-03-25T00:39:49.121Z",
31// Post: &atproto.RepoStrongRef{
32// Cid: "bafyreiczmyne5jd4lpax5ttyb5p2fbcageyt6fsthdpyymecokcsmyh4a4",
33// Uri: "at://did:plc:2zmxikig2sj7gqaezl5gntae/app.bsky.feed.post/3ll5zuomua22x",
34// },
35// Title: "We're back up! Once again water in the firehose. Link cards if this stays stable",
36// Url: &sp,
37// }
38// lsv := &streamplace.Livestream_LivestreamView{
39// Author: &bsky.ActorDefs_ProfileViewBasic{
40// Handle: "iame.li",
41// Did: "did:plc:2zmxikig2sj7gqaezl5gntae",
42// },
43// Cid: "bafyreib2ohz45jileumnuwa3wdoo3o7caikfyq467eanleqcscouh5wery",
44// IndexedAt: "2025-03-25T01:16:14Z",
45// Record: &lexutil.LexiconTypeDecoder{Val: ls},
46// Uri: "at://did:plc:2zmxikig2sj7gqaezl5gntae/place.stream.livestream/3ll5zuop2k22x",
47// }
48// linkCard, err := linker.GenerateStreamerCard(context.Background(), u, lsv)
49// require.NoError(t, err)
50// require.Equal(t, outputStreamerCard, string(linkCard))
51// }
52
53// func TestGenerateDefaultCard(t *testing.T) {
54// linker, err := NewLinker(context.Background(), []byte(input))
55// require.NoError(t, err)
56// require.NotNil(t, linker)
57
58// u, err := url.Parse("https://stream.place/iame.li")
59// require.NoError(t, err)
60// linkCard, err := linker.GenerateDefaultCard(context.Background(), u)
61// require.NoError(t, err)
62// require.Equal(t, outputDefaultCard, string(linkCard))
63// }
64
65// const input string = `<!doctype html>
66// <html lang="en">
67// <head>
68// <meta charset="utf-8" />
69// <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
70// <meta
71// name="viewport"
72// content="width=device-width, initial-scale=1, shrink-to-fit=no"
73// />
74// <title>Streamplace</title>
75// <style id="expo-reset">
76// html,
77// body {
78// height: 100%;
79// }
80// body {
81// overflow: hidden;
82// }
83// #root {
84// display: flex;
85// height: 100%;
86// flex: 1;
87// }
88// </style>
89// <style>
90// html {
91// background-color: black;
92// }
93// </style>
94// <link rel="preload" href="/_expo/static/css/index-90f1b618e9e200dcb98a9b55d1941582.css" as="style"><link rel="stylesheet" href="/_expo/static/css/index-90f1b618e9e200dcb98a9b55d1941582.css"><link rel="shortcut icon" href="/favicon.ico" /></head>
95
96// <body>
97// <noscript> You need to enable JavaScript to run this app. </noscript>
98// <div id="root"></div>
99// <script src="/_expo/static/js/web/entrypoint-35bf1c89449fbda0007e7522d13b215f.js" defer></script>
100// </body>
101// </html>`
102
103// const outputStreamerCard string = `<!DOCTYPE html><html lang="en"><head>
104// <meta charset="utf-8"/>
105// <meta httpequiv="X-UA-Compatible" content="IE=edge"/>
106// <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
107// <title>Streamplace</title>
108// <style id="expo-reset">
109// html,
110// body {
111// height: 100%;
112// }
113// body {
114// overflow: hidden;
115// }
116// #root {
117// display: flex;
118// height: 100%;
119// flex: 1;
120// }
121// </style>
122// <style>
123// html {
124// background-color: black;
125// }
126// </style>
127// <link rel="preload" href="/_expo/static/css/index-90f1b618e9e200dcb98a9b55d1941582.css" as="style"/><link rel="stylesheet" href="/_expo/static/css/index-90f1b618e9e200dcb98a9b55d1941582.css"/><link rel="shortcut icon" href="/favicon.ico"/><title>Stream.place</title><meta name="description" content="Stream.place is open-source livestreaming on the AT Protocol."/><meta property="og:url" content="https://stream.place/iame.li"/><meta property="og:type" content="website"/><meta property="og:title" content="Stream.place"/><meta property="og:description" content="Stream.place is open-source livestreaming on the AT Protocol."/><meta property="og:image" content="https://stream.place/linkbanner.png"/><meta name="twitter:card" content="summary_large_image"/><meta property="twitter:domain" content="stream.place"/><meta property="twitter:url" content="https://stream.place/iame.li"/><meta name="twitter:title" content="Stream.place"/><meta name="twitter:description" content="Stream.place is open-source livestreaming on the AT Protocol."/><meta name="twitter:image" content="https://stream.place/linkbanner.png"/></head>
128
129// <body>
130// <noscript> You need to enable JavaScript to run this app. </noscript>
131// <div id="root"></div>
132// <script src="/_expo/static/js/web/entrypoint-35bf1c89449fbda0007e7522d13b215f.js" defer=""></script>
133
134// </body></html>`
135// const outputDefaultCard string = ``