MCPcopy
hub / github.com/writefreely/writefreely / PersonObject

Method PersonObject

collections.go:330–359  ·  view source on GitHub ↗
(ids ...int64)

Source from the content-addressed store, hash-verified

328var isAvatarChar = regexp.MustCompile("[a-z0-9]").MatchString
329
330func (c *Collection) PersonObject(ids ...int64) *activitystreams.Person {
331 accountRoot := c.FederatedAccount()
332 p := activitystreams.NewPerson(accountRoot)
333 p.URL = c.CanonicalURL()
334 uname := c.Alias
335 p.PreferredUsername = uname
336 p.Name = c.DisplayTitle()
337 p.Summary = c.Description
338 if p.Name != "" {
339 if av := c.AvatarURL(); av != "" {
340 p.Icon = activitystreams.Image{
341 Type: "Image",
342 MediaType: "image/png",
343 URL: av,
344 }
345 }
346 }
347
348 collID := c.ID
349 if len(ids) > 0 {
350 collID = ids[0]
351 }
352 pub, priv := c.db.GetAPActorKeys(collID)
353 if pub != nil {
354 p.AddPubKey(pub)
355 p.SetPrivKey(priv)
356 }
357
358 return p
359}
360
361func (c *Collection) AvatarURL() string {
362 fl := string(unicode.ToLower([]rune(c.DisplayTitle())[0]))

Callers 6

handleViewCollectionFunction · 0.80
resolveIRIFunction · 0.80
deleteFederatedPostFunction · 0.80
federatePostFunction · 0.80

Calls 5

FederatedAccountMethod · 0.95
CanonicalURLMethod · 0.95
DisplayTitleMethod · 0.95
AvatarURLMethod · 0.95
GetAPActorKeysMethod · 0.65

Tested by

no test coverage detected