dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 816b286e105b05a217428d17a9462b425979b696
parent 9cbc00298602d1adb1423b16badc4b57776c0a3c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 19 Mar 2023 02:45:21 -0700

auto HB "legit market" retards

Diffstat:
Mpkg/web/handlers/api/v1/spamInterceptor.go | 15+++++++++++++++
Mpkg/web/handlers/api/v1/spamInterceptor_test.go | 19+++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/api/v1/spamInterceptor.go b/pkg/web/handlers/api/v1/spamInterceptor.go @@ -71,6 +71,12 @@ func checkSpam(db *database.DkfDB, origMessage string, authUser *database.User) } } + // Auto HB "legit market" retards + if isAskingLegitMarketRetard(authUser, lowerCaseMessage) { + dutils.SelfHellBan(db, *authUser) + return nil + } + // Auto HB "new here" retards if isNewHereRetard(authUser, lowerCaseMessage) { dutils.SelfHellBan(db, *authUser) @@ -124,6 +130,15 @@ func checkSpam(db *database.DkfDB, origMessage string, authUser *database.User) return nil } +func isAskingLegitMarketRetard(authUser *database.User, lowerCaseMessage string) bool { + if authUser.GeneralMessagesCount <= 5 { + if strings.Contains(lowerCaseMessage, "legit market") { + return true + } + } + return false +} + func isNewHereRetard(authUser *database.User, lowerCaseMessage string) bool { if authUser.GeneralMessagesCount <= 5 { if strings.Contains(lowerCaseMessage, "new here") { diff --git a/pkg/web/handlers/api/v1/spamInterceptor_test.go b/pkg/web/handlers/api/v1/spamInterceptor_test.go @@ -24,3 +24,22 @@ func Test_isNewHereRetard(t *testing.T) { }) } } + +func Test_isAskingLegitMarketRetard(t *testing.T) { + type args struct { + authUser *database.User + lowerCaseMessage string + } + tests := []struct { + name string + args args + want bool + }{ + {name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "hello anybody know of any legit market places ? its getting tough on here to find any that actually do what they supposed to "}, want: true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equalf(t, tt.want, isAskingLegitMarketRetard(tt.args.authUser, tt.args.lowerCaseMessage), "isAskingLegitMarketRetard(%v, %v)", tt.args.authUser, tt.args.lowerCaseMessage) + }) + } +}