tangled
alpha
login
or
join now
whey.party
/
red-dwarf-server
13
fork
atom
collection of golang services under the Red Dwarf umbrella
server.reddwarf.app
bluesky
reddwarf
microcosm
appview
13
fork
atom
overview
issues
pulls
pipelines
basic labeler getServices
whey.party
3 months ago
d74fabe0
36c46532
+94
-4
2 changed files
expand all
collapse all
unified
split
main.go
shims
lex
app
bsky
actor
defs
profileview.go
+82
main.go
···
199
199
c.JSON(http.StatusOK, nil)
200
200
})
201
201
202
202
+
router.GET("/xrpc/app.bsky.labeler.getServices",
203
203
+
func(c *gin.Context) {
204
204
+
dids := c.QueryArray("dids")
205
205
+
206
206
+
labelers := make([]*appbsky.LabelerGetServices_Output_Views_Elem, 0, len(dids))
207
207
+
//profiles := make([]*appbsky.ActorDefs_ProfileViewDetailed, 0, len(dids))
208
208
+
209
209
+
for _, v := range dids {
210
210
+
did, err := utils.NewDID(v)
211
211
+
if err != nil {
212
212
+
continue
213
213
+
}
214
214
+
labelerprofile, _, _ := appbskyactordefs.ProfileView(ctx, did, sl, BSKYIMAGECDN_URL)
215
215
+
labelerserviceresponse, _ := agnostic.RepoGetRecord(ctx, sl, "", "app.bsky.labeler.service", string(did), "self")
216
216
+
var labelerservice appbsky.LabelerService
217
217
+
if err := json.Unmarshal(*labelerserviceresponse.Value, &labelerservice); err != nil {
218
218
+
continue
219
219
+
}
220
220
+
221
221
+
a := "account"
222
222
+
b := "record"
223
223
+
c := "chat"
224
224
+
225
225
+
placeholderTypes := []*string{&a, &b, &c}
226
226
+
227
227
+
labeler := &appbsky.LabelerGetServices_Output_Views_Elem{
228
228
+
LabelerDefs_LabelerView: &appbsky.LabelerDefs_LabelerView{
229
229
+
// LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.labeler.defs#labelerView"`
230
230
+
LexiconTypeID: "app.bsky.labeler.defs#labelerView",
231
231
+
// Cid string `json:"cid" cborgen:"cid"`
232
232
+
Cid: *labelerserviceresponse.Cid,
233
233
+
// Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"`
234
234
+
Creator: labelerprofile,
235
235
+
// IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
236
236
+
IndexedAt: labelerservice.CreatedAt,
237
237
+
// Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"`
238
238
+
Labels: nil, // seems to always be empty?
239
239
+
// LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"`
240
240
+
LikeCount: nil, // placeholder sorry
241
241
+
// Uri string `json:"uri" cborgen:"uri"`
242
242
+
Uri: labelerserviceresponse.Uri,
243
243
+
// Viewer *LabelerDefs_LabelerViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"`
244
244
+
Viewer: nil,
245
245
+
},
246
246
+
LabelerDefs_LabelerViewDetailed: &appbsky.LabelerDefs_LabelerViewDetailed{
247
247
+
// LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.labeler.defs#labelerViewDetailed"`
248
248
+
LexiconTypeID: "app.bsky.labeler.defs#labelerViewDetailed",
249
249
+
// Cid string `json:"cid" cborgen:"cid"`
250
250
+
Cid: *labelerserviceresponse.Cid,
251
251
+
// Creator *ActorDefs_ProfileView `json:"creator" cborgen:"creator"`
252
252
+
Creator: labelerprofile,
253
253
+
// IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
254
254
+
IndexedAt: labelerservice.CreatedAt,
255
255
+
// Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"`
256
256
+
Labels: nil, // seems to always be empty?
257
257
+
// LikeCount *int64 `json:"likeCount,omitempty" cborgen:"likeCount,omitempty"`
258
258
+
LikeCount: nil, // placeholder sorry
259
259
+
// Policies *LabelerDefs_LabelerPolicies `json:"policies" cborgen:"policies"`
260
260
+
Policies: labelerservice.Policies,
261
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
262
+
// ReasonTypes []*string `json:"reasonTypes,omitempty" cborgen:"reasonTypes,omitempty"`
263
263
+
ReasonTypes: nil, //usually not even present
264
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
265
+
// SubjectCollections []string `json:"subjectCollections,omitempty" cborgen:"subjectCollections,omitempty"`
266
266
+
SubjectCollections: nil, //usually not even present
267
267
+
// // subjectTypes: The set of subject types (account, record, etc) this service accepts reports on.
268
268
+
// SubjectTypes []*string `json:"subjectTypes,omitempty" cborgen:"subjectTypes,omitempty"`
269
269
+
SubjectTypes: placeholderTypes,
270
270
+
// Uri string `json:"uri" cborgen:"uri"`
271
271
+
Uri: labelerserviceresponse.Uri,
272
272
+
// Viewer *LabelerDefs_LabelerViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"`
273
273
+
Viewer: nil,
274
274
+
},
275
275
+
}
276
276
+
labelers = append(labelers, labeler)
277
277
+
}
278
278
+
279
279
+
c.JSON(http.StatusOK, &appbsky.LabelerGetServices_Output{
280
280
+
Views: labelers,
281
281
+
})
282
282
+
})
283
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
66
-
avatar := utils.MakeImageCDN(did, imgcdn, "avatar", profile.Avatar.Ref.String())
66
66
+
var avatar *string
67
67
+
if profile.Avatar != nil {
68
68
+
url := utils.MakeImageCDN(did, imgcdn, "avatar", profile.Avatar.Ref.String())
69
69
+
avatar = &url
70
70
+
}
67
71
68
72
return &appbsky.ActorDefs_ProfileView{
69
73
Associated: nil,
70
70
-
Avatar: &avatar,
74
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
97
-
banner := utils.MakeImageCDN(did, imgcdn, "banner", profile.Banner.Ref.String())
101
101
+
var banner *string
102
102
+
if profile.Banner != nil {
103
103
+
url := utils.MakeImageCDN(did, imgcdn, "banner", profile.Banner.Ref.String())
104
104
+
banner = &url
105
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
104
-
Banner: &banner,
112
112
+
Banner: banner,
105
113
CreatedAt: profileview.CreatedAt,
106
114
Debug: profileview.Debug,
107
115
Description: profileview.Description,