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

basic labeler getServices

+94 -4
+82
main.go
··· 199 199 c.JSON(http.StatusOK, nil) 200 200 }) 201 201 202 + router.GET("/xrpc/app.bsky.labeler.getServices", 203 + func(c *gin.Context) { 204 + dids := c.QueryArray("dids") 205 + 206 + labelers := make([]*appbsky.LabelerGetServices_Output_Views_Elem, 0, len(dids)) 207 + //profiles := make([]*appbsky.ActorDefs_ProfileViewDetailed, 0, len(dids)) 208 + 209 + for _, v := range dids { 210 + did, err := utils.NewDID(v) 211 + if err != nil { 212 + continue 213 + } 214 + labelerprofile, _, _ := appbskyactordefs.ProfileView(ctx, did, sl, BSKYIMAGECDN_URL) 215 + labelerserviceresponse, _ := agnostic.RepoGetRecord(ctx, sl, "", "app.bsky.labeler.service", string(did), "self") 216 + var labelerservice appbsky.LabelerService 217 + if err := json.Unmarshal(*labelerserviceresponse.Value, &labelerservice); err != nil { 218 + continue 219 + } 220 + 221 + a := "account" 222 + b := "record" 223 + c := "chat" 224 + 225 + placeholderTypes := []*string{&a, &b, &c} 226 + 227 + labeler := &appbsky.LabelerGetServices_Output_Views_Elem{ 228 + LabelerDefs_LabelerView: &appbsky.LabelerDefs_LabelerView{ 229 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.labeler.defs#labelerView"` 230 + LexiconTypeID: "app.bsky.labeler.defs#labelerView", 231 + // Cid string `json:"cid" cborgen:"cid"` 232 + Cid: *labelerserviceresponse.Cid, 233 + // Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"` 234 + Creator: labelerprofile, 235 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 236 + IndexedAt: labelerservice.CreatedAt, 237 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 238 + Labels: nil, // seems to always be empty? 239 + // LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"` 240 + LikeCount: nil, // placeholder sorry 241 + // Uri string `json:"uri" cborgen:"uri"` 242 + Uri: labelerserviceresponse.Uri, 243 + // Viewer *LabelerDefs_LabelerViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"` 244 + Viewer: nil, 245 + }, 246 + LabelerDefs_LabelerViewDetailed: &appbsky.LabelerDefs_LabelerViewDetailed{ 247 + // LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.labeler.defs#labelerViewDetailed"` 248 + LexiconTypeID: "app.bsky.labeler.defs#labelerViewDetailed", 249 + // Cid string `json:"cid" cborgen:"cid"` 250 + Cid: *labelerserviceresponse.Cid, 251 + // Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"` 252 + Creator: labelerprofile, 253 + // IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 254 + IndexedAt: labelerservice.CreatedAt, 255 + // Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` 256 + Labels: nil, // seems to always be empty? 257 + // LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"` 258 + LikeCount: nil, // placeholder sorry 259 + // Policies *LabelerDefs_LabelerPolicies `json:"policies" cborgen:"policies"` 260 + Policies: labelerservice.Policies, 261 + // // reasonTypes: The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed. 262 + // ReasonTypes []*string `json:"reasonTypes,omitempty" cborgen:"reasonTypes,omitempty"` 263 + ReasonTypes: nil, //usually not even present 264 + // // subjectCollections: Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type. 265 + // SubjectCollections []string `json:"subjectCollections,omitempty" cborgen:"subjectCollections,omitempty"` 266 + SubjectCollections: nil, //usually not even present 267 + // // subjectTypes: The set of subject types (account, record, etc) this service accepts reports on. 268 + // SubjectTypes []*string `json:"subjectTypes,omitempty" cborgen:"subjectTypes,omitempty"` 269 + SubjectTypes: placeholderTypes, 270 + // Uri string `json:"uri" cborgen:"uri"` 271 + Uri: labelerserviceresponse.Uri, 272 + // Viewer *LabelerDefs_LabelerViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"` 273 + Viewer: nil, 274 + }, 275 + } 276 + labelers = append(labelers, labeler) 277 + } 278 + 279 + c.JSON(http.StatusOK, &appbsky.LabelerGetServices_Output{ 280 + Views: labelers, 281 + }) 282 + }) 283 + 202 284 router.GET("/", func(c *gin.Context) { 203 285 log.Println("hello worldio !") 204 286 clientUUID := sticket.GetUUIDFromRequest(c.Request)
+12 -4
shims/lex/app/bsky/actor/defs/profileview.go
··· 63 63 displayName = string(did) 64 64 } 65 65 } 66 - avatar := utils.MakeImageCDN(did, imgcdn, "avatar", profile.Avatar.Ref.String()) 66 + var avatar *string 67 + if profile.Avatar != nil { 68 + url := utils.MakeImageCDN(did, imgcdn, "avatar", profile.Avatar.Ref.String()) 69 + avatar = &url 70 + } 67 71 68 72 return &appbsky.ActorDefs_ProfileView{ 69 73 Associated: nil, 70 - Avatar: &avatar, 74 + Avatar: avatar, 71 75 CreatedAt: profile.CreatedAt, 72 76 Debug: nil, 73 77 Description: profile.Description, ··· 94 98 } 95 99 followerCount := int64(followerCount_Out.Total) 96 100 97 - banner := utils.MakeImageCDN(did, imgcdn, "banner", profile.Banner.Ref.String()) 101 + var banner *string 102 + if profile.Banner != nil { 103 + url := utils.MakeImageCDN(did, imgcdn, "banner", profile.Banner.Ref.String()) 104 + banner = &url 105 + } 98 106 99 107 nilCount := int64(-1) 100 108 101 109 return &appbsky.ActorDefs_ProfileViewDetailed{ 102 110 Associated: profileview.Associated, 103 111 Avatar: profileview.Avatar, 104 - Banner: &banner, 112 + Banner: banner, 105 113 CreatedAt: profileview.CreatedAt, 106 114 Debug: profileview.Debug, 107 115 Description: profileview.Description,