-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
49 lines (43 loc) · 1000 Bytes
/
utils.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
package vvvot
import (
"context"
"strings"
"github.com/bluesky-social/indigo/api/bsky"
"github.com/bluesky-social/indigo/xrpc"
)
func isMentionedToMe(ctx context.Context, me *xrpc.AuthInfo, post *bsky.FeedPost) bool {
if me.Did != "" {
for _, facet := range post.Facets {
for _, f := range facet.Features {
if v := f.RichtextFacet_Mention; v != nil {
if me.Did == v.Did {
return true
}
}
}
}
}
if me.Handle != "" {
if strings.Contains(post.Text, me.Handle) {
return true
}
}
return false
}
func isRepliedAlready(ctx context.Context, me *xrpc.AuthInfo, thread *bsky.FeedGetPostThread_Output) bool {
if thread.Thread == nil {
return false
}
if thread.Thread.FeedDefs_ThreadViewPost == nil {
return false
}
for _, reply := range thread.Thread.FeedDefs_ThreadViewPost.Replies {
if reply.FeedDefs_ThreadViewPost == nil {
continue
}
if reply.FeedDefs_ThreadViewPost.Post.Author.Did == me.Did {
return true
}
}
return false
}