(ids ...int64)
| 328 | var isAvatarChar = regexp.MustCompile("[a-z0-9]").MatchString |
| 329 | |
| 330 | func (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 | |
| 361 | func (c *Collection) AvatarURL() string { |
| 362 | fl := string(unicode.ToLower([]rune(c.DisplayTitle())[0])) |
no test coverage detected