-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity.go
54 lines (44 loc) · 944 Bytes
/
activity.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package filters
import vocab "github.com/go-ap/activitypub"
func Actor(fns ...Check) Check {
return actorChecks(fns)
}
type actorChecks []Check
func (a actorChecks) Match(it vocab.Item) bool {
if vocab.IsNil(it) {
return false
}
act, err := vocab.ToIntransitiveActivity(it)
if err != nil {
return false
}
return All(a...).Match(act.Actor)
}
func Target(fns ...Check) Check {
return targetChecks(fns)
}
type targetChecks []Check
func (t targetChecks) Match(it vocab.Item) bool {
if vocab.IsNil(it) {
return false
}
act, err := vocab.ToIntransitiveActivity(it)
if err != nil {
return false
}
return All(t...).Match(act.Target)
}
func Object(fns ...Check) Check {
return objectChecks(fns)
}
type objectChecks []Check
func (o objectChecks) Match(it vocab.Item) bool {
if vocab.IsNil(it) {
return false
}
act, err := vocab.ToActivity(it)
if err != nil {
return false
}
return All(o...).Match(act.Object)
}