Tagging bots in actors table

This commit is contained in:
Farhan Khan 2021-12-16 18:19:21 -05:00
parent f5b9285e44
commit 056e89beed
2 changed files with 15 additions and 2 deletions

View File

@ -241,7 +241,19 @@ func check_actor(uri string) int {
return 406 // Unable to unmarshal body of message
}
_, err = pool.Exec(context.Background(), "INSERT INTO actors (document, instance) VALUES($1, $2)", jsondocument, actorjson.instance)
var bot bool
if actorjson.Type == "Service" {
bot = true
} else {
bot = false
for _, botinstance := range settings.Alwaysbot {
if strings.Index(uri, "https://"+botinstance+"/") == 0 {
bot = true
}
}
}
_, err = pool.Exec(context.Background(), "INSERT INTO actors (document, instance, bot) VALUES($1, $2, $3)", jsondocument, actorjson.instance, bot)
if err != nil {
logWarn("Error inserting %s into `actors`: "+uri, err)
return 407 // Unable to insert actor

View File

@ -2,7 +2,8 @@ CREATE TABLE IF NOT EXISTS actors (
id SERIAL PRIMARY KEY,
document JSONB,
identifiedat TIMESTAMP with time zone DEFAULT now(),
instance VARCHAR(1000) NOT NULL
instance VARCHAR(1000) NOT NULL,
bot BOOL DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS activities (