-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathspam.go
51 lines (44 loc) · 1.24 KB
/
spam.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
package spam
import (
"github.com/tonkeeper/opentonapi/pkg/core"
"github.com/tonkeeper/opentonapi/pkg/oas"
rules "github.com/tonkeeper/scam_backoffice_rules"
"github.com/tonkeeper/tongo"
"github.com/tonkeeper/tongo/ton"
)
type Filter struct {
Rules rules.Rules
}
func NewSpamFilter() *Filter {
return &Filter{
Rules: rules.GetDefaultRules(),
}
}
func (f Filter) CheckActions(actions []oas.Action, viewer *ton.AccountID, initiator *ton.AccountID) bool {
var comment string
for _, action := range actions {
switch {
case action.TonTransfer.IsSet():
comment = action.TonTransfer.Value.Comment.Value
case action.JettonTransfer.IsSet():
comment = action.JettonTransfer.Value.Comment.Value
case action.NftItemTransfer.IsSet():
comment = action.NftItemTransfer.Value.Comment.Value
default:
continue
}
for _, rule := range f.Rules {
rate := rule.Evaluate(comment)
if rate == rules.Drop || rate == rules.MarkScam {
return true
}
}
}
return false
}
func (f Filter) JettonTrust(address tongo.AccountID, symbol, name, image string) core.TrustType {
return core.TrustNone
}
func (f Filter) NftTrust(address tongo.AccountID, collection *ton.AccountID, description, image string) core.TrustType {
return core.TrustNone
}