From 699948b7d3cd00d8b2abb074c4e9be460abdd2f7 Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Wed, 29 Jan 2025 14:15:52 +0000 Subject: [PATCH 1/2] rename CheckActions --- pkg/api/event_converters.go | 4 ++-- pkg/api/interfaces.go | 2 +- pkg/api/jetton_converters.go | 2 +- pkg/api/nft_converters.go | 2 +- pkg/spam/spam.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/api/event_converters.go b/pkg/api/event_converters.go index 1bbfb508..2384ed19 100644 --- a/pkg/api/event_converters.go +++ b/pkg/api/event_converters.go @@ -805,7 +805,7 @@ func (h *Handler) toEvent(ctx context.Context, trace *core.Trace, result *bath.A } event.Actions[i] = convertedAction } - event.IsScam = h.spamFilter.CheckActions(event.Actions, nil, trace.Account) + event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, nil, trace.Account) previews := make(map[tongo.AccountID]oas.JettonPreview) for _, flow := range result.ValueFlow.Accounts { for jettonMaster := range flow.Jettons { @@ -886,7 +886,7 @@ func (h *Handler) toAccountEvent(ctx context.Context, account tongo.AccountID, t e.Actions = append(e.Actions, convertedAction) } if h.spamFilter != nil { - e.IsScam = h.spamFilter.CheckActions(e.Actions, &account, trace.Account) + e.IsScam = h.spamFilter.CheckEvent(e.EventID, e.Actions, &account, trace.Account) } if len(e.Actions) == 0 { e.Actions = []oas.Action{ diff --git a/pkg/api/interfaces.go b/pkg/api/interfaces.go index b10bc038..20bc098b 100644 --- a/pkg/api/interfaces.go +++ b/pkg/api/interfaces.go @@ -184,7 +184,7 @@ type scoreSource interface { } type SpamFilter interface { - CheckActions(actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool + CheckEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool JettonTrust(address tongo.AccountID, symbol, name, image string) core.TrustType AccountTrust(address tongo.AccountID) core.TrustType NftTrust(ctx context.Context, address tongo.AccountID, collection *ton.AccountID, description, image string) core.TrustType diff --git a/pkg/api/jetton_converters.go b/pkg/api/jetton_converters.go index 613cfe85..29d6257c 100644 --- a/pkg/api/jetton_converters.go +++ b/pkg/api/jetton_converters.go @@ -97,7 +97,7 @@ func (h *Handler) convertJettonHistory(ctx context.Context, account ton.AccountI } event.Actions = append(event.Actions, convertedAction) } - event.IsScam = h.spamFilter.CheckActions(event.Actions, &account, trace.Account) + event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, &account, trace.Account) if len(event.Actions) == 0 { continue } diff --git a/pkg/api/nft_converters.go b/pkg/api/nft_converters.go index 15ad659b..c8a90009 100644 --- a/pkg/api/nft_converters.go +++ b/pkg/api/nft_converters.go @@ -163,7 +163,7 @@ func (h *Handler) convertNftHistory(ctx context.Context, account tongo.AccountID } event.Actions = append(event.Actions, convertedAction) } - event.IsScam = h.spamFilter.CheckActions(event.Actions, &account, trace.Account) + event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, &account, trace.Account) if len(event.Actions) > 0 { events = append(events, event) lastLT = trace.Lt diff --git a/pkg/spam/spam.go b/pkg/spam/spam.go index f4851a0c..f20e6c7d 100644 --- a/pkg/spam/spam.go +++ b/pkg/spam/spam.go @@ -19,7 +19,7 @@ func NewSpamFilter() *Filter { } } -func (f Filter) CheckActions(actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool { +func (f Filter) CheckEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool { var comment string for _, action := range actions { switch { From 598134b234386cfc797156a00aa9da363b8ad0a6 Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Wed, 29 Jan 2025 14:19:33 +0000 Subject: [PATCH 2/2] rename to IsScamEvent --- pkg/api/event_converters.go | 4 ++-- pkg/api/interfaces.go | 2 +- pkg/api/jetton_converters.go | 2 +- pkg/api/nft_converters.go | 2 +- pkg/spam/spam.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/api/event_converters.go b/pkg/api/event_converters.go index 2384ed19..e91c09e8 100644 --- a/pkg/api/event_converters.go +++ b/pkg/api/event_converters.go @@ -805,7 +805,7 @@ func (h *Handler) toEvent(ctx context.Context, trace *core.Trace, result *bath.A } event.Actions[i] = convertedAction } - event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, nil, trace.Account) + event.IsScam = h.spamFilter.IsScamEvent(event.EventID, event.Actions, nil, trace.Account) previews := make(map[tongo.AccountID]oas.JettonPreview) for _, flow := range result.ValueFlow.Accounts { for jettonMaster := range flow.Jettons { @@ -886,7 +886,7 @@ func (h *Handler) toAccountEvent(ctx context.Context, account tongo.AccountID, t e.Actions = append(e.Actions, convertedAction) } if h.spamFilter != nil { - e.IsScam = h.spamFilter.CheckEvent(e.EventID, e.Actions, &account, trace.Account) + e.IsScam = h.spamFilter.IsScamEvent(e.EventID, e.Actions, &account, trace.Account) } if len(e.Actions) == 0 { e.Actions = []oas.Action{ diff --git a/pkg/api/interfaces.go b/pkg/api/interfaces.go index 20bc098b..59b5dd31 100644 --- a/pkg/api/interfaces.go +++ b/pkg/api/interfaces.go @@ -184,7 +184,7 @@ type scoreSource interface { } type SpamFilter interface { - CheckEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool + IsScamEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool JettonTrust(address tongo.AccountID, symbol, name, image string) core.TrustType AccountTrust(address tongo.AccountID) core.TrustType NftTrust(ctx context.Context, address tongo.AccountID, collection *ton.AccountID, description, image string) core.TrustType diff --git a/pkg/api/jetton_converters.go b/pkg/api/jetton_converters.go index 29d6257c..48d2ffe8 100644 --- a/pkg/api/jetton_converters.go +++ b/pkg/api/jetton_converters.go @@ -97,7 +97,7 @@ func (h *Handler) convertJettonHistory(ctx context.Context, account ton.AccountI } event.Actions = append(event.Actions, convertedAction) } - event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, &account, trace.Account) + event.IsScam = h.spamFilter.IsScamEvent(event.EventID, event.Actions, &account, trace.Account) if len(event.Actions) == 0 { continue } diff --git a/pkg/api/nft_converters.go b/pkg/api/nft_converters.go index c8a90009..9af5f2ef 100644 --- a/pkg/api/nft_converters.go +++ b/pkg/api/nft_converters.go @@ -163,7 +163,7 @@ func (h *Handler) convertNftHistory(ctx context.Context, account tongo.AccountID } event.Actions = append(event.Actions, convertedAction) } - event.IsScam = h.spamFilter.CheckEvent(event.EventID, event.Actions, &account, trace.Account) + event.IsScam = h.spamFilter.IsScamEvent(event.EventID, event.Actions, &account, trace.Account) if len(event.Actions) > 0 { events = append(events, event) lastLT = trace.Lt diff --git a/pkg/spam/spam.go b/pkg/spam/spam.go index f20e6c7d..758a8ae3 100644 --- a/pkg/spam/spam.go +++ b/pkg/spam/spam.go @@ -19,7 +19,7 @@ func NewSpamFilter() *Filter { } } -func (f Filter) CheckEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool { +func (f Filter) IsScamEvent(eventId string, actions []oas.Action, viewer *ton.AccountID, initiator ton.AccountID) bool { var comment string for _, action := range actions { switch {