diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-11-10 15:45:27 -0400 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | f1f2044c2f2bc24ea2a08c58b4517e1e07f4039c (patch) | |
tree | fbc684b8f4a13145bfaebd71ee6f224cea169eef /db | |
parent | e15bf8cd1375f24251929ff3e13f883f692ee03a (diff) |
it compiles now
Diffstat (limited to 'db')
-rw-r--r-- | db/cache.go | 13 | ||||
-rw-r--r-- | db/database.go | 36 |
2 files changed, 30 insertions, 19 deletions
diff --git a/db/cache.go b/db/cache.go index 6f1ee8f..dff1987 100644 --- a/db/cache.go +++ b/db/cache.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/FChannel0/FChannel-Server/activitypub" + "github.com/FChannel0/FChannel-Server/util" "github.com/FChannel0/FChannel-Server/webfinger" _ "github.com/lib/pq" ) @@ -81,9 +82,9 @@ func WriteActorObjectToCache(obj activitypub.ObjectBase) (activitypub.ObjectBase } func WriteActivitytoCache(obj activitypub.ObjectBase) error { - obj.Name = EscapeString(obj.Name) - obj.Content = EscapeString(obj.Content) - obj.AttributedTo = EscapeString(obj.AttributedTo) + obj.Name = util.EscapeString(obj.Name) + obj.Content = util.EscapeString(obj.Content) + obj.AttributedTo = util.EscapeString(obj.AttributedTo) query := `select id from cacheactivitystream where id=$1` @@ -113,9 +114,9 @@ func WriteActivitytoCache(obj activitypub.ObjectBase) error { } func WriteActivitytoCacheWithAttachment(obj activitypub.ObjectBase, attachment activitypub.ObjectBase, preview activitypub.NestedObjectBase) error { - obj.Name = EscapeString(obj.Name) - obj.Content = EscapeString(obj.Content) - obj.AttributedTo = EscapeString(obj.AttributedTo) + obj.Name = util.EscapeString(obj.Name) + obj.Content = util.EscapeString(obj.Content) + obj.AttributedTo = util.EscapeString(obj.AttributedTo) query := `select id from cacheactivitystream where id=$1` diff --git a/db/database.go b/db/database.go index dfa66aa..8845f24 100644 --- a/db/database.go +++ b/db/database.go @@ -531,9 +531,9 @@ func WriteWalletToDB(obj activitypub.ObjectBase) error { } func WriteActivitytoDB(obj activitypub.ObjectBase) error { - obj.Name = EscapeString(obj.Name) - obj.Content = EscapeString(obj.Content) - obj.AttributedTo = EscapeString(obj.AttributedTo) + obj.Name = util.EscapeString(obj.Name) + obj.Content = util.EscapeString(obj.Content) + obj.AttributedTo = util.EscapeString(obj.AttributedTo) query := `insert into activitystream (id, type, name, content, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)` @@ -543,9 +543,9 @@ func WriteActivitytoDB(obj activitypub.ObjectBase) error { func WriteActivitytoDBWithAttachment(obj activitypub.ObjectBase, attachment activitypub.ObjectBase, preview activitypub.NestedObjectBase) { - obj.Name = EscapeString(obj.Name) - obj.Content = EscapeString(obj.Content) - obj.AttributedTo = EscapeString(obj.AttributedTo) + obj.Name = util.EscapeString(obj.Name) + obj.Content = util.EscapeString(obj.Content) + obj.AttributedTo = util.EscapeString(obj.AttributedTo) query := `insert into activitystream (id, type, name, content, attachment, preview, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)` @@ -1877,13 +1877,6 @@ func DeleteCaptchaCodeDB(verify string) error { return os.Remove("./" + verify) } -func EscapeString(text string) string { - // TODO: not enough - - text = strings.Replace(text, "<", "<", -1) - return text -} - func GetActorReportedTotal(id string) (int, error) { query := `select count(id) from reported where board=$1` @@ -2538,3 +2531,20 @@ func AddFollower(id string, follower string) error { _, err := db.Exec(query, id, follower) return err } + +func IsHashBanned(hash string) (bool, error) { + var h string + + query := `select hash from bannedmedia where hash=$1` + + rows, err := db.Query(query, hash) + if err != nil { + return true, err + } + defer rows.Close() + + rows.Next() + err = rows.Scan(&h) + + return h == hash, err +} |