tangled
alpha
login
or
join now
moth11.net
/
rvcx
3
fork
atom
backend for xcvr appview
3
fork
atom
overview
issues
4
pulls
pipelines
add broadcast image to channel lexicon stream
moth11.net
5 months ago
24b0d9aa
1f917f56
+68
-5
3 changed files
expand all
collapse all
unified
split
lexicons
org
xcvr
notes.lex
server
internal
model
channelLexiconStream.go
types
lexicons.go
+4
-5
lexicons/org/xcvr/notes.lex
···
103
103
104
104
image: def
105
105
alt: string
106
106
-
blob: blob
106
106
+
blob?: blob
107
107
aspectRatio?: aspectRatio
108
108
109
109
aspectRatio: def
···
112
112
113
113
video: def
114
114
alt: string
115
115
-
blob: blob
115
115
+
blob?: blob
116
116
# captions?
117
117
118
118
messageView: def
···
146
146
147
147
imageView: def
148
148
alt: string
149
149
-
src: string
149
149
+
src?: string
150
150
aspectRatio?: aspectRatio
151
151
152
152
videoView: def
153
153
alt: string
154
154
-
src: string
154
154
+
src?: string
155
155
# captions?
156
156
-
157
156
158
157
signedMessageView: def
159
158
uri: uri
+36
server/internal/model/channelLexiconStream.go
···
3
3
import (
4
4
"context"
5
5
"errors"
6
6
+
"fmt"
6
7
"net/http"
8
8
+
"os"
7
9
"rvcx/internal/atputils"
10
10
+
"rvcx/internal/lex"
8
11
"rvcx/internal/types"
9
12
"time"
10
13
···
132
135
cm.broadcast(mv)
133
136
return nil
134
137
}
138
138
+
139
139
+
func (m *Model) BroadcastImage(uri string, media *types.Image) error {
140
140
+
cm := m.uriMap[uri]
141
141
+
if cm == nil {
142
142
+
return errors.New("failed to map uri to lsm!")
143
143
+
}
144
144
+
pv, err := m.store.GetProfileView(media.DID, context.Background())
145
145
+
if err != nil {
146
146
+
return errors.New("failed to get profile view: " + err.Error())
147
147
+
}
148
148
+
ar := lex.AspectRatio{
149
149
+
Width: *media.Width,
150
150
+
Height: *media.Height,
151
151
+
}
152
152
+
src := fmt.Sprintf("%s/xrpc/org.xcvr.lrc.getImage?uri=%s", os.Getenv("MY_IDENTITY"), media.URI)
153
153
+
154
154
+
img := types.ImageView{
155
155
+
Alt: media.Alt,
156
156
+
Src: &src,
157
157
+
AspectRatio: &ar,
158
158
+
}
159
159
+
mv := types.MediaView{
160
160
+
URI: media.URI,
161
161
+
Author: *pv,
162
162
+
Image: &img,
163
163
+
Nick: media.Nick,
164
164
+
Color: media.Color,
165
165
+
SignetURI: media.SignetURI,
166
166
+
PostedAt: media.PostedAt,
167
167
+
}
168
168
+
cm.broadcast(mv)
169
169
+
return nil
170
170
+
}
+28
server/internal/types/lexicons.go
···
227
227
IndexedAt time.Time
228
228
}
229
229
230
230
+
type MediaView struct {
231
231
+
Type string `json:"$type,const=org.xcvr.lrc.defs#messageView"`
232
232
+
URI string `json:"uri"`
233
233
+
Author ProfileView `json:"author"`
234
234
+
Image *ImageView `json:"imageView,omitempty"`
235
235
+
Nick *string `json:"nick,omitempty"`
236
236
+
Color *uint32 `json:"color,omitempty"`
237
237
+
SignetURI string `json:"signetURI"`
238
238
+
PostedAt time.Time `json:"postedAt"`
239
239
+
}
240
240
+
241
241
+
type ImageView struct {
242
242
+
Alt string `json:"alt"`
243
243
+
Src *string `json:"src,omitempty"`
244
244
+
AspectRatio *lex.AspectRatio `json:"AspectRatio,omitempty"`
245
245
+
}
246
246
+
230
247
type ParseMediaRequest struct {
231
248
Nick *string `json:"nick,omitempty"`
232
249
Color *uint32 `json:"color,omitempty"`
···
234
251
Image *lex.Image `json:"image,omitempty"`
235
252
Type string `json:"type"`
236
253
}
254
254
+
255
255
+
func (m MediaView) MarshalJSON() ([]byte, error) {
256
256
+
type Alias MediaView
257
257
+
return json.Marshal(&struct {
258
258
+
Type string `json:"$type"`
259
259
+
*Alias
260
260
+
}{
261
261
+
Type: "org.xcvr.lrc.defs#mediaView",
262
262
+
Alias: (*Alias)(&m),
263
263
+
})
264
264
+
}