-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathextractors.go
More file actions
63 lines (59 loc) · 1.05 KB
/
extractors.go
File metadata and controls
63 lines (59 loc) · 1.05 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package activitypub
func PreferredNameOf(it Item) string {
if !IsObject(it) {
return ""
}
var cont string
_ = OnActor(it, func(act *Actor) error {
if act.PreferredUsername != nil {
cont = act.PreferredUsername.First().String()
}
return nil
})
return cont
}
func ContentOf(it Item) string {
if !IsObject(it) {
return ""
}
var cont string
_ = OnObject(it, func(ob *Object) error {
if ob.Content != nil {
cont = ob.Content.First().String()
}
return nil
})
return cont
}
func SummaryOf(it Item) string {
if !IsObject(it) {
return ""
}
var cont string
_ = OnObject(it, func(ob *Object) error {
if ob.Summary != nil {
cont = ob.Summary.First().String()
}
return nil
})
return cont
}
func NameOf(it Item) string {
var name string
if IsLink(it) {
_ = OnLink(it, func(lnk *Link) error {
if lnk.Name != nil {
name = lnk.Name.First().String()
}
return nil
})
} else {
_ = OnObject(it, func(ob *Object) error {
if ob.Name != nil {
name = ob.Name.First().String()
}
return nil
})
}
return name
}