collection of golang services under the Red Dwarf umbrella server.reddwarf.app
bluesky reddwarf microcosm appview
15
fork

Configure Feed

Select the types of activity you want to include in your feed.

PostView_Embed is now more modular

+417 -56
+2 -2
main.go
··· 408 408 go func(i int, raw string) { 409 409 defer wg.Done() 410 410 411 - post, _, _ := appbskyfeeddefs.PostView(ctx, raw, sl, cs, BSKYIMAGECDN_URL, viewer) 411 + post, _, _ := appbskyfeeddefs.PostView(ctx, raw, sl, cs, BSKYIMAGECDN_URL, viewer, false) 412 412 413 413 results[i].view = post 414 414 }(i, raw) ··· 537 537 skeletonposts, 538 538 20, 539 539 func(ctx context.Context, raw *appbsky.FeedDefs_SkeletonFeedPost) (*appbsky.FeedDefs_FeedViewPost, error) { 540 - post, _, err := appbskyfeeddefs.PostView(ctx, raw.Post, sl, cs, BSKYIMAGECDN_URL, viewer) 540 + post, _, err := appbskyfeeddefs.PostView(ctx, raw.Post, sl, cs, BSKYIMAGECDN_URL, viewer, false) 541 541 if err != nil { 542 542 return nil, err 543 543 }
+403 -52
shims/lex/app/bsky/feed/defs/embed.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "log" 5 6 7 + "github.com/bluesky-social/indigo/api/atproto" 6 8 appbsky "github.com/bluesky-social/indigo/api/bsky" 7 9 "github.com/bluesky-social/indigo/atproto/syntax" 8 10 "tangled.org/whey.party/red-dwarf-server/microcosm" 11 + appbskyactordefs "tangled.org/whey.party/red-dwarf-server/shims/lex/app/bsky/actor/defs" 9 12 "tangled.org/whey.party/red-dwarf-server/shims/utils" 10 13 ) 14 + 15 + func notFoundRecordEmbed(uri string) *appbsky.EmbedRecord_View_Record { 16 + return &appbsky.EmbedRecord_View_Record{ 17 + EmbedRecord_ViewNotFound: &appbsky.EmbedRecord_ViewNotFound{ 18 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.record#viewNotFound"` 19 + LexiconTypeID: "app.bsky.embed.record#viewNotFound", 20 + // NotFound bool `json:"notFound" cborgen:"notFound"` 21 + NotFound: true, 22 + // Uri string `json:"uri" cborgen:"uri"` 23 + Uri: uri, 24 + }} 25 + } 11 26 12 27 func PostView_Embed(ctx context.Context, postaturi string, feedPost *appbsky.FeedPost, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID) (*appbsky.FeedDefs_PostView_Embed, error) { 13 28 if feedPost.Embed == nil { ··· 21 36 22 37 // determine type 23 38 if feedPost.Embed.EmbedImages != nil { 24 - //embedType = "EmbedImages" 25 - 26 - // thumb: `https://${cdn}/img/feed_thumbnail/plain/${did}/${link}@jpeg`, 27 - // fullsize: `https://${cdn}/img/feed_fullsize/plain/${did}/${link}@jpeg`, 28 - var images []*appbsky.EmbedImages_ViewImage 29 - for _, rawimg := range feedPost.Embed.EmbedImages.Images { 30 - 31 - var feed_thumbnail string 32 - var feed_fullsize string 33 - if rawimg.Image != nil { 34 - u := utils.MakeImageCDN(utils.DID(aturi.Authority().String()), imgcdn, "feed_thumbnail", rawimg.Image.Ref.String()) 35 - feed_thumbnail = u 36 - uf := utils.MakeImageCDN(utils.DID(aturi.Authority().String()), imgcdn, "feed_fullsize", rawimg.Image.Ref.String()) 37 - feed_fullsize = uf 38 - } 39 - img := appbsky.EmbedImages_ViewImage{ 40 - // // alt: Alt text description of the image, for accessibility. 41 - // Alt string `json:"alt" cborgen:"alt"` 42 - Alt: rawimg.Alt, 43 - // AspectRatio *EmbedDefs_AspectRatio `json:"aspectRatio,omitempty" cborgen:"aspectRatio,omitempty"` 44 - AspectRatio: rawimg.AspectRatio, 45 - // // fullsize: Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View. 46 - // Fullsize string `json:"fullsize" cborgen:"fullsize"` 47 - Fullsize: feed_fullsize, 48 - // // thumb: Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View. 49 - // Thumb string `json:"thumb" cborgen:"thumb"` 50 - Thumb: feed_thumbnail, 51 - } 52 - images = append(images, &img) 53 - } 54 - return &appbsky.FeedDefs_PostView_Embed{ 55 - // EmbedImages_View *EmbedImages_View 56 - EmbedImages_View: &appbsky.EmbedImages_View{ 57 - LexiconTypeID: "app.bsky.embed.images#view", 58 - Images: images, 59 - }, 60 - // EmbedVideo_View *EmbedVideo_View 61 - // EmbedExternal_View *EmbedExternal_View 62 - // EmbedRecord_View *EmbedRecord_View 63 - // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 64 - }, nil 39 + embedImage := EmbedImagesViewExtractor(ctx, aturi, feedPost.Embed.EmbedImages, sl, cs, imgcdn, viewer) 40 + return embedImage, nil 65 41 } 66 42 if feedPost.Embed.EmbedVideo != nil { 67 43 return nil, nil ··· 69 45 return &appbsky.FeedDefs_PostView_Embed{ 70 46 // EmbedImages_View *EmbedImages_View 71 47 // EmbedVideo_View *EmbedVideo_View 48 + EmbedVideo_View: &appbsky.EmbedVideo_View{ 49 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.video#view"` 50 + // Alt *string `json:"alt,omitempty" cborgen:"alt,omitempty"` 51 + // AspectRatio *EmbedDefs_AspectRatio `json:"aspectRatio,omitempty" cborgen:"aspectRatio,omitempty"` 52 + // Cid string `json:"cid" cborgen:"cid"` 53 + // Playlist string `json:"playlist" cborgen:"playlist"` 54 + // Thumbnail *string `json:"thumbnail,omitempty" cborgen:"thumbnail,omitempty"` 55 + }, 72 56 // EmbedExternal_View *EmbedExternal_View 73 57 // EmbedRecord_View *EmbedRecord_View 74 58 // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 75 59 }, nil 76 60 } 77 61 if feedPost.Embed.EmbedExternal != nil { 78 - return nil, nil 79 - //embedType = "EmbedExternal" 80 - return &appbsky.FeedDefs_PostView_Embed{ 81 - // EmbedImages_View *EmbedImages_View 82 - // EmbedVideo_View *EmbedVideo_View 83 - // EmbedExternal_View *EmbedExternal_View 84 - // EmbedRecord_View *EmbedRecord_View 85 - // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 86 - }, nil 62 + embedExternal := EmbedExternalViewExtractor(ctx, aturi, feedPost.Embed.EmbedExternal, sl, cs, imgcdn, viewer) 63 + return embedExternal, nil 87 64 } 88 65 if feedPost.Embed.EmbedRecord != nil { 89 - return nil, nil 66 + //return nil, nil 67 + // sigh this is a big one 90 68 //embedType = "EmbedRecord" 69 + 70 + /* 71 + const author: $Typed<AppBskyActorDefs.ProfileViewBasic> = asTyped({ 72 + $type: "app.bsky.actor.defs#profileViewBasic" as const, 73 + did: quotedIdentity.did, 74 + handle: quotedIdentity.handle, 75 + displayName: quotedProfile.value.displayName ?? quotedIdentity.handle, 76 + avatar: quotedProfile.value.avatar?.ref?.$link 77 + ? `https://${cdn}/img/avatar/plain/${quotedIdentity.did}/${quotedProfile.value.avatar.ref.$link}@jpeg` 78 + : undefined, 79 + viewer: {}, 80 + labels: [], 81 + }); 82 + 83 + const viewRecord: $Typed<AppBskyEmbedRecord.ViewRecord> = asTyped({ 84 + $type: "app.bsky.embed.record#viewRecord" as const, 85 + uri: quotedPost.uri, 86 + cid: quotedPost.cid, 87 + author, 88 + value: quotedPost.value, 89 + indexedAt: quotedPost.value.createdAt, 90 + embeds: quotedPost.value.embed ? [quotedPost.value.embed] : undefined, 91 + }); 92 + */ 93 + 94 + var record *appbsky.EmbedRecord_View_Record = EmbedRecordViewExtractor(ctx, feedPost.Embed.EmbedRecord.Record, sl, cs, imgcdn, viewer) 95 + if record == nil { 96 + return nil, nil 97 + } 98 + 91 99 return &appbsky.FeedDefs_PostView_Embed{ 92 100 // EmbedImages_View *EmbedImages_View 93 101 // EmbedVideo_View *EmbedVideo_View 94 102 // EmbedExternal_View *EmbedExternal_View 95 103 // EmbedRecord_View *EmbedRecord_View 104 + EmbedRecord_View: &appbsky.EmbedRecord_View{ 105 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.record#view"` 106 + LexiconTypeID: "app.bsky.embed.record#view", 107 + // Record *EmbedRecord_View_Record `json:"record" cborgen:"record"` 108 + Record: record, 109 + // Record: &appbsky.EmbedRecord_View_Record{ 110 + // // EmbedRecord_ViewRecord *EmbedRecord_ViewRecord 111 + // // EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound 112 + // // EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked 113 + // // EmbedRecord_ViewDetached *EmbedRecord_ViewDetached 114 + // // FeedDefs_GeneratorView *FeedDefs_GeneratorView 115 + // // GraphDefs_ListView *GraphDefs_ListView 116 + // // LabelerDefs_LabelerView *LabelerDefs_LabelerView 117 + // // GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic 118 + // }, 119 + }, 96 120 // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 97 121 }, nil 98 122 } 99 123 if feedPost.Embed.EmbedRecordWithMedia != nil { 100 - return nil, nil 124 + //return nil, nil 101 125 //embedType = "EmbedRecordWithMedia" 126 + 127 + var record *appbsky.EmbedRecord_View_Record = EmbedRecordViewExtractor(ctx, feedPost.Embed.EmbedRecordWithMedia.Record.Record, sl, cs, imgcdn, viewer) 128 + if record == nil { 129 + return nil, nil 130 + } 131 + var embedrecordview *appbsky.EmbedRecord_View 132 + if record.EmbedRecord_ViewRecord != nil { 133 + embedrecordview = &appbsky.EmbedRecord_View{ 134 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.record#view"` 135 + LexiconTypeID: "app.bsky.embed.record#view", 136 + // Record *EmbedRecord_View_Record `json:"record" cborgen:"record"` 137 + Record: record, 138 + } 139 + } 140 + 141 + var embedmediaview *appbsky.EmbedRecordWithMedia_View_Media 142 + 143 + if feedPost.Embed.EmbedRecordWithMedia.Media.EmbedImages != nil { 144 + embedImage := EmbedImagesViewExtractor(ctx, aturi, feedPost.Embed.EmbedRecordWithMedia.Media.EmbedImages, sl, cs, imgcdn, viewer) 145 + embedmediaview = &appbsky.EmbedRecordWithMedia_View_Media{ 146 + // EmbedImages_View *EmbedImages_View 147 + EmbedImages_View: &appbsky.EmbedImages_View{ 148 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.images#view"` 149 + LexiconTypeID: "app.bsky.embed.images#view", 150 + // Images []*EmbedImages_ViewImage `json:"images" cborgen:"images"` 151 + Images: embedImage.EmbedImages_View.Images, 152 + }, 153 + // EmbedVideo_View *EmbedVideo_View 154 + // EmbedExternal_View *EmbedExternal_View 155 + } 156 + } 157 + if feedPost.Embed.EmbedRecordWithMedia.Media.EmbedVideo != nil { 158 + // // video extractor 159 + // embedmediaview = &appbsky.EmbedRecordWithMedia_View_Media{ 160 + // // EmbedImages_View *EmbedImages_View 161 + // // EmbedVideo_View *EmbedVideo_View 162 + // // EmbedExternal_View *EmbedExternal_View 163 + // } 164 + } 165 + if feedPost.Embed.EmbedRecordWithMedia.Media.EmbedExternal != nil { 166 + embedExternal := EmbedExternalViewExtractor(ctx, aturi, feedPost.Embed.EmbedExternal, sl, cs, imgcdn, viewer) 167 + embedmediaview = &appbsky.EmbedRecordWithMedia_View_Media{ 168 + // EmbedImages_View *EmbedImages_View 169 + // EmbedVideo_View *EmbedVideo_View 170 + // EmbedExternal_View *EmbedExternal_View 171 + EmbedExternal_View: &appbsky.EmbedExternal_View{ 172 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.external#view"` 173 + LexiconTypeID: "app.bsky.embed.external#view", 174 + // External *EmbedExternal_ViewExternal `json:"external" cborgen:"external"` 175 + External: embedExternal.EmbedExternal_View.External, 176 + }, 177 + } 178 + } 179 + 102 180 return &appbsky.FeedDefs_PostView_Embed{ 103 181 // EmbedImages_View *EmbedImages_View 104 182 // EmbedVideo_View *EmbedVideo_View 105 183 // EmbedExternal_View *EmbedExternal_View 106 184 // EmbedRecord_View *EmbedRecord_View 107 185 // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 186 + EmbedRecordWithMedia_View: &appbsky.EmbedRecordWithMedia_View{ 187 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.recordWithMedia#view"` 188 + LexiconTypeID: "", 189 + // Media *EmbedRecordWithMedia_View_Media `json:"media" cborgen:"media"` 190 + Media: embedmediaview, 191 + // Record *EmbedRecord_View `json:"record" cborgen:"record"` 192 + Record: embedrecordview, 193 + }, 108 194 }, nil 109 195 } 110 196 111 197 return nil, nil 112 198 } 199 + 200 + func EmbedImagesViewExtractor(ctx context.Context, aturi syntax.ATURI, embedImages *appbsky.EmbedImages, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID) *appbsky.FeedDefs_PostView_Embed { 201 + //embedType = "EmbedImages" 202 + // thumb: `https://${cdn}/img/feed_thumbnail/plain/${did}/${link}@jpeg`, 203 + // fullsize: `https://${cdn}/img/feed_fullsize/plain/${did}/${link}@jpeg`, 204 + var images []*appbsky.EmbedImages_ViewImage 205 + for _, rawimg := range embedImages.Images { 206 + 207 + var feed_thumbnail string 208 + var feed_fullsize string 209 + if rawimg.Image != nil { 210 + u := utils.MakeImageCDN(utils.DID(aturi.Authority().String()), imgcdn, "feed_thumbnail", rawimg.Image.Ref.String()) 211 + feed_thumbnail = u 212 + uf := utils.MakeImageCDN(utils.DID(aturi.Authority().String()), imgcdn, "feed_fullsize", rawimg.Image.Ref.String()) 213 + feed_fullsize = uf 214 + } 215 + img := appbsky.EmbedImages_ViewImage{ 216 + // // alt: Alt text description of the image, for accessibility. 217 + // Alt string `json:"alt" cborgen:"alt"` 218 + Alt: rawimg.Alt, 219 + // AspectRatio *EmbedDefs_AspectRatio `json:"aspectRatio,omitempty" cborgen:"aspectRatio,omitempty"` 220 + AspectRatio: rawimg.AspectRatio, 221 + // // fullsize: Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View. 222 + // Fullsize string `json:"fullsize" cborgen:"fullsize"` 223 + Fullsize: feed_fullsize, 224 + // // thumb: Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View. 225 + // Thumb string `json:"thumb" cborgen:"thumb"` 226 + Thumb: feed_thumbnail, 227 + } 228 + images = append(images, &img) 229 + } 230 + return &appbsky.FeedDefs_PostView_Embed{ 231 + // EmbedImages_View *EmbedImages_View 232 + EmbedImages_View: &appbsky.EmbedImages_View{ 233 + LexiconTypeID: "app.bsky.embed.images#view", 234 + Images: images, 235 + }, 236 + // EmbedVideo_View *EmbedVideo_View 237 + // EmbedExternal_View *EmbedExternal_View 238 + // EmbedRecord_View *EmbedRecord_View 239 + // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 240 + } 241 + 242 + } 243 + 244 + func EmbedExternalViewExtractor(ctx context.Context, aturi syntax.ATURI, embedExternal *appbsky.EmbedExternal, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID) *appbsky.FeedDefs_PostView_Embed { 245 + // todo: gif embeds needs special handling i think? maybe? 246 + //return nil, nil 247 + //embedType = "EmbedExternal" 248 + rawimg := embedExternal.External 249 + var thumbnail *string 250 + if rawimg.Thumb != nil { 251 + u := utils.MakeImageCDN(utils.DID(aturi.Authority().String()), imgcdn, "feed_thumbnail", rawimg.Thumb.Ref.String()) 252 + thumbnail = &u 253 + } 254 + return &appbsky.FeedDefs_PostView_Embed{ 255 + // EmbedImages_View *EmbedImages_View 256 + // EmbedVideo_View *EmbedVideo_View 257 + // EmbedExternal_View *EmbedExternal_View 258 + EmbedExternal_View: &appbsky.EmbedExternal_View{ 259 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.external#view"` 260 + LexiconTypeID: "app.bsky.embed.external#view", 261 + // External *EmbedExternal_ViewExternal `json:"external" cborgen:"external"` 262 + External: &appbsky.EmbedExternal_ViewExternal{ 263 + // Description string `json:"description" cborgen:"description"` 264 + Description: embedExternal.External.Description, 265 + // Thumb *string `json:"thumb,omitempty" cborgen:"thumb,omitempty"` 266 + Thumb: thumbnail, 267 + // Title string `json:"title" cborgen:"title"` 268 + Title: embedExternal.External.Title, 269 + // Uri string `json:"uri" cborgen:"uri"` 270 + Uri: embedExternal.External.Uri, 271 + }, 272 + }, 273 + // EmbedRecord_View *EmbedRecord_View 274 + // EmbedRecordWithMedia_View *EmbedRecordWithMedia_View 275 + } 276 + } 277 + 278 + func EmbedRecordViewExtractor(ctx context.Context, record *atproto.RepoStrongRef, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID) *appbsky.EmbedRecord_View_Record { 279 + if record == nil { 280 + log.Println("[EmbedRecord_View_Record] no record *(????)") 281 + return nil 282 + } 283 + raw := record.Uri 284 + aturi, err := syntax.ParseATURI(raw) 285 + if err != nil { 286 + log.Println("[EmbedRecord_View_Record] bad aturi") 287 + return nil 288 + } 289 + collection := aturi.Collection().String() 290 + 291 + if collection == "app.bsky.feed.post" { 292 + //t.EmbedRecord_ViewRecord.LexiconTypeID = "app.bsky.embed.record#viewRecord" 293 + profileViewBasic, _, err := appbskyactordefs.ProfileViewBasic(ctx, utils.DID(aturi.Authority().String()), sl, imgcdn) 294 + if err != nil { 295 + log.Println("[EmbedRecord_View_Record] profileviewbasic failed") 296 + return notFoundRecordEmbed(aturi.String()) 297 + } 298 + 299 + postView, _, err := PostView(ctx, aturi.String(), sl, cs, imgcdn, viewer, true) 300 + if err != nil { 301 + log.Println("[EmbedRecord_View_Record] postview failed") 302 + return notFoundRecordEmbed(aturi.String()) 303 + } 304 + 305 + // postRecordResponse, err_r := agnostic.RepoGetRecord(ctx, sl, "", "app.bsky.feed.post", aturi.Authority().String(), aturi.RecordKey().String()) 306 + // if err_r != nil { 307 + // return notFoundRecordEmbed(aturi.String()) 308 + // } 309 + // var postRecord appbsky.FeedPost 310 + // if err := json.Unmarshal(*postRecordResponse.Value, &postRecord); err != nil { 311 + // return notFoundRecordEmbed(aturi.String()) 312 + // } 313 + 314 + // lexicontypedecoder := &util.LexiconTypeDecoder{Val: &postRecord} 315 + 316 + return &appbsky.EmbedRecord_View_Record{ 317 + // EmbedRecord_ViewRecord *EmbedRecord_ViewRecord 318 + EmbedRecord_ViewRecord: &appbsky.EmbedRecord_ViewRecord{ 319 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.record#viewRecord"` 320 + LexiconTypeID: "app.bsky.embed.record#viewRecord", 321 + // Author *ActorDefs_ProfileViewBasic `json:"author" cborgen:"author"` 322 + Author: profileViewBasic, 323 + // Cid string `json:"cid" cborgen:"cid"` 324 + Cid: postView.Cid, 325 + // Embeds []*EmbedRecord_ViewRecord_Embeds_Elem `json:"embeds,omitempty" cborgen:"embeds,omitempty"` 326 + Embeds: nil, 327 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 328 + IndexedAt: postView.IndexedAt, 329 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 330 + Labels: postView.Labels, 331 + // LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"` 332 + LikeCount: postView.LikeCount, 333 + // QuoteCount *int64 `json:"quoteCount,omitempty" cborgen:"quoteCount,omitempty"` 334 + QuoteCount: postView.QuoteCount, 335 + // ReplyCount *int64 `json:"replyCount,omitempty" cborgen:"replyCount,omitempty"` 336 + ReplyCount: postView.ReplyCount, 337 + // RepostCount *int64 `json:"repostCount,omitempty" cborgen:"repostCount,omitempty"` 338 + RepostCount: postView.RepostCount, 339 + // Uri string `json:"uri" cborgen:"uri"` 340 + Uri: postView.Uri, 341 + // // value: The record data itself. 342 + // Value *lexutil.LexiconTypeDecoder `json:"value" cborgen:"value"` 343 + Value: postView.Record, 344 + }, 345 + // EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound 346 + // EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked 347 + // EmbedRecord_ViewDetached *EmbedRecord_ViewDetached 348 + // FeedDefs_GeneratorView *FeedDefs_GeneratorView 349 + // GraphDefs_ListView *GraphDefs_ListView 350 + // LabelerDefs_LabelerView *LabelerDefs_LabelerView 351 + // GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic 352 + } 353 + } 354 + if collection == "app.bsky.feed.generator" { 355 + return notFoundRecordEmbed(aturi.String()) 356 + return nil 357 + //t.FeedDefs_GeneratorView.LexiconTypeID = "app.bsky.feed.defs#generatorView" 358 + return &appbsky.EmbedRecord_View_Record{ 359 + // EmbedRecord_ViewRecord *EmbedRecord_ViewRecord 360 + // EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound 361 + // EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked 362 + // EmbedRecord_ViewDetached *EmbedRecord_ViewDetached 363 + // FeedDefs_GeneratorView *FeedDefs_GeneratorView 364 + FeedDefs_GeneratorView: &appbsky.FeedDefs_GeneratorView{ 365 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.defs#generatorView"` 366 + // AcceptsInteractions *bool `json:"acceptsInteractions,omitempty" cborgen:"acceptsInteractions,omitempty"` 367 + // Avatar *string `json:"avatar,omitempty" cborgen:"avatar,omitempty"` 368 + // Cid string `json:"cid" cborgen:"cid"` 369 + // ContentMode *string `json:"contentMode,omitempty" cborgen:"contentMode,omitempty"` 370 + // Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"` 371 + // Description *string `json:"description,omitempty" cborgen:"description,omitempty"` 372 + // DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"` 373 + // Did string `json:"did" cborgen:"did"` 374 + // DisplayName string `json:"displayName" cborgen:"displayName"` 375 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 376 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 377 + // LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"` 378 + // Uri string `json:"uri" cborgen:"uri"` 379 + // Viewer *FeedDefs_GeneratorViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"` 380 + }, 381 + // GraphDefs_ListView *GraphDefs_ListView 382 + // LabelerDefs_LabelerView *LabelerDefs_LabelerView 383 + // GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic 384 + } 385 + } 386 + if collection == "app.bsky.graph.list" { 387 + return notFoundRecordEmbed(aturi.String()) 388 + return nil 389 + //t.GraphDefs_ListView.LexiconTypeID = "app.bsky.graph.defs#listView" 390 + return &appbsky.EmbedRecord_View_Record{ 391 + // EmbedRecord_ViewRecord *EmbedRecord_ViewRecord 392 + // EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound 393 + // EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked 394 + // EmbedRecord_ViewDetached *EmbedRecord_ViewDetached 395 + // FeedDefs_GeneratorView *FeedDefs_GeneratorView 396 + // GraphDefs_ListView *GraphDefs_ListView 397 + GraphDefs_ListView: &appbsky.GraphDefs_ListView{ 398 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.defs#listView"` 399 + // Avatar *string `json:"avatar,omitempty" cborgen:"avatar,omitempty"` 400 + // Cid string `json:"cid" cborgen:"cid"` 401 + // Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"` 402 + // Description *string `json:"description,omitempty" cborgen:"description,omitempty"` 403 + // DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"` 404 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 405 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 406 + // ListItemCount *int64 `json:"listItemCount,omitempty" cborgen:"listItemCount,omitempty"` 407 + // Name string `json:"name" cborgen:"name"` 408 + // Purpose *string `json:"purpose" cborgen:"purpose"` 409 + // Uri string `json:"uri" cborgen:"uri"` 410 + // Viewer *GraphDefs_ListViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"` 411 + }, 412 + // LabelerDefs_LabelerView *LabelerDefs_LabelerView 413 + // GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic 414 + } 415 + } 416 + // if t.LabelerDefs_LabelerView != nil { 417 + // t.LabelerDefs_LabelerView.LexiconTypeID = "app.bsky.labeler.defs#labelerView" 418 + // return json.Marshal(t.LabelerDefs_LabelerView) 419 + // } 420 + if collection == "app.bsky.graph.starterpack" { 421 + return notFoundRecordEmbed(aturi.String()) 422 + return nil 423 + //t.GraphDefs_StarterPackViewBasic.LexiconTypeID = "app.bsky.graph.defs#starterPackViewBasic" 424 + return &appbsky.EmbedRecord_View_Record{ 425 + // EmbedRecord_ViewRecord *EmbedRecord_ViewRecord 426 + // EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound 427 + // EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked 428 + // EmbedRecord_ViewDetached *EmbedRecord_ViewDetached 429 + // FeedDefs_GeneratorView *FeedDefs_GeneratorView 430 + // GraphDefs_ListView *GraphDefs_ListView 431 + // LabelerDefs_LabelerView *LabelerDefs_LabelerView 432 + // GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic 433 + GraphDefs_StarterPackViewBasic: &appbsky.GraphDefs_StarterPackViewBasic{ 434 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.defs#starterPackViewBasic"` 435 + // Cid string `json:"cid" cborgen:"cid"` 436 + // Creator *ActorDefs_ProfileViewBasic `json:"creator" cborgen:"creator"` 437 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 438 + // JoinedAllTimeCount *int64 `json:"joinedAllTimeCount,omitempty" cborgen:"joinedAllTimeCount,omitempty"` 439 + // JoinedWeekCount *int64 `json:"joinedWeekCount,omitempty" cborgen:"joinedWeekCount,omitempty"` 440 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 441 + // ListItemCount *int64 `json:"listItemCount,omitempty" cborgen:"listItemCount,omitempty"` 442 + // Record *lexutil.LexiconTypeDecoder `json:"record" cborgen:"record"` 443 + // Uri string `json:"uri" cborgen:"uri"` 444 + }, 445 + } 446 + } 447 + 448 + // if t.EmbedRecord_ViewNotFound != nil { 449 + // t.EmbedRecord_ViewNotFound.LexiconTypeID = "app.bsky.embed.record#viewNotFound" 450 + // return json.Marshal(t.EmbedRecord_ViewNotFound) 451 + // } 452 + // if t.EmbedRecord_ViewBlocked != nil { 453 + // t.EmbedRecord_ViewBlocked.LexiconTypeID = "app.bsky.embed.record#viewBlocked" 454 + // return json.Marshal(t.EmbedRecord_ViewBlocked) 455 + // } 456 + // if t.EmbedRecord_ViewDetached != nil { 457 + // t.EmbedRecord_ViewDetached.LexiconTypeID = "app.bsky.embed.record#viewDetached" 458 + // return json.Marshal(t.EmbedRecord_ViewDetached) 459 + // } 460 + return notFoundRecordEmbed(aturi.String()) 461 + return nil 462 + 463 + }
+12 -2
shims/lex/app/bsky/feed/defs/postview.go
··· 5 5 "encoding/json" 6 6 7 7 "github.com/bluesky-social/indigo/api/agnostic" 8 + comatproto "github.com/bluesky-social/indigo/api/atproto" 8 9 appbsky "github.com/bluesky-social/indigo/api/bsky" 9 10 "github.com/bluesky-social/indigo/atproto/syntax" 10 11 "tangled.org/whey.party/red-dwarf-server/microcosm" ··· 17 18 "tangled.org/whey.party/red-dwarf-server/shims/utils" 18 19 ) 19 20 20 - func PostView(ctx context.Context, postaturi string, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID) (*appbsky.FeedDefs_PostView, *appbsky.FeedPost, error) { 21 + func PostView(ctx context.Context, postaturi string, sl *microcosm.MicrocosmClient, cs *microcosm.MicrocosmClient, imgcdn string, viewer *utils.DID, disableEmbed bool) (*appbsky.FeedDefs_PostView, *appbsky.FeedPost, error) { 21 22 aturi, err := syntax.ParseATURI(postaturi) 22 23 if err != nil { 23 24 return nil, nil, err ··· 39 40 if err := json.Unmarshal(*postRecordResponse.Value, &postRecord); err != nil { 40 41 return nil, nil, err 41 42 } 42 - postView_Embed, err := PostView_Embed(ctx, postaturi, &postRecord, sl, cs, imgcdn, viewer) 43 + var postView_Embed *appbsky.FeedDefs_PostView_Embed 44 + if !disableEmbed { 45 + postView_Embed, err = PostView_Embed(ctx, postaturi, &postRecord, sl, cs, imgcdn, viewer) 46 + if err != nil { 47 + postView_Embed = nil 48 + } 49 + } 43 50 44 51 profile, _, _ := appbskyactordefs.ProfileViewBasic(ctx, repoDID, sl, imgcdn) 45 52 ··· 157 164 //log.Println("viewer is nil") 158 165 } 159 166 167 + var emptyLabelsArray []*comatproto.LabelDefs_Label = []*comatproto.LabelDefs_Label{} 168 + 160 169 return &appbsky.FeedDefs_PostView{ 161 170 // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.defs#postView"` 162 171 LexiconTypeID: "app.bsky.feed.defs#postView", ··· 172 181 // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 173 182 IndexedAt: postRecord.CreatedAt, 174 183 // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 184 + Labels: emptyLabelsArray, 175 185 // LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"` 176 186 LikeCount: &likeCount, 177 187 // QuoteCount *int64 `json:"quoteCount,omitempty" cborgen:"quoteCount,omitempty"`