Filter bot posts and add env vars for instance and tag configuration
This commit is contained in:
@@ -2,6 +2,7 @@ package helpers
|
||||
|
||||
import (
|
||||
"CatsOfMastodonBotGo/models"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -20,11 +21,10 @@ func GetExistingAccountIds(db *gorm.DB) []string {
|
||||
db.Model(&models.Account{}).Pluck("acc_id", &existingAccountIds)
|
||||
return existingAccountIds
|
||||
}
|
||||
|
||||
func GetNewPosts(existingPostIds []string, posts []models.Post) []models.Post {
|
||||
var newPosts []models.Post = nil
|
||||
for _, post := range posts {
|
||||
if !arrayContains(existingPostIds, post.ID) {
|
||||
if !arrayContains(existingPostIds, post.ID) && len(post.Attachments) > 0 && !post.Account.IsBot {
|
||||
newPosts = append(newPosts, post)
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,11 @@ func GetNewAccounts(existingAccountIds []string, posts []models.Post) []models.A
|
||||
return newAccounts
|
||||
}
|
||||
|
||||
func InsertNewPosts(db *gorm.DB, newPosts []models.Post) int{
|
||||
func InsertNewPosts(db *gorm.DB, newPosts []models.Post) int {
|
||||
return int(db.Create(&newPosts).RowsAffected)
|
||||
}
|
||||
|
||||
func InsertNewAccounts(db *gorm.DB, newAccounts []models.Account) int{
|
||||
func InsertNewAccounts(db *gorm.DB, newAccounts []models.Account) int {
|
||||
return int(db.Create(&newAccounts).RowsAffected)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,3 @@ func arrayContains(arr []string, str string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user