-
Notifications
You must be signed in to change notification settings - Fork 14
/
actor.go
40 lines (33 loc) · 1.29 KB
/
actor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package asnormalizer
import (
"github.com/benpate/hannibal/streams"
"github.com/benpate/hannibal/vocab"
)
// Actor normalizes an Actor document
func Actor(document streams.Document) map[string]any {
result := map[string]any{
// Profile
vocab.PropertyType: document.Type(),
vocab.PropertyID: document.ID(),
vocab.PropertyName: document.Name(),
vocab.PropertyPreferredUsername: document.PreferredUsername(),
vocab.PropertySummary: document.Summary(),
vocab.PropertyImage: Image(document.Image()),
vocab.PropertyIcon: Image(document.Icon()),
vocab.PropertyTag: Tags(document.Tag()),
// Collections
vocab.PropertyInbox: document.Inbox().String(),
vocab.PropertyOutbox: document.Outbox().Value(), // using raw outbox value because RSS feeds stuff data in here.
vocab.PropertyLiked: document.Liked().String(),
vocab.PropertyFollowers: document.Followers().String(),
vocab.PropertyFollowing: document.Following().String(),
}
// Cryptography
if publicKey := document.PublicKey(); publicKey.NotNil() {
result[vocab.PropertyPublicKey] = map[string]any{
vocab.PropertyID: publicKey.ID(),
vocab.PropertyPublicKeyPEM: publicKey.PublicKeyPEM(),
}
}
return result
}