diff options
author | FChannel <=> | 2021-01-18 13:02:03 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-18 13:02:03 -0800 |
commit | 02e5d46ed214d0efbc3fc566dea7f10415e3fadf (patch) | |
tree | e8400860239da186780b6ca2277232284fd9e05f | |
parent | 7ef5c8866930a887d866c92301069e5719c4b11e (diff) |
fix for syncing local and remote post count totals
-rw-r--r-- | Database.go | 40 | ||||
-rw-r--r-- | config-init | 7 | ||||
-rw-r--r-- | main.go | 9 |
3 files changed, 50 insertions, 6 deletions
diff --git a/Database.go b/Database.go index f7b011d..7f69efe 100644 --- a/Database.go +++ b/Database.go @@ -531,7 +531,45 @@ func GetObjectRepliesDBCount(db *sql.DB, parent ObjectBase) (int, int) { rows.Next() rows.Scan(&countImg) - return countId, countImg + post, img := GetObjectRepliesRemoteCount(db, parent) + + return countId + post, countImg + img +} + +func GetObjectRepliesRemoteCount(db *sql.DB, parent ObjectBase) (int, int) { + var nColl CollectionBase + var result []ObjectBase + query := `select id from replies where id not in (select id from activitystream) and inreplyto=$1` + + rows, err := db.Query(query, parent.Id) + + CheckError(err, "could not get remote id query") + + defer rows.Close() + for rows.Next() { + var id string + rows.Scan(&id) + + coll := GetCollectionFromID(id) + + for _, e := range coll.OrderedItems { + result = append(result, e) + } + } + + nColl.OrderedItems = result + + var posts int + var imgs int + + for _, e := range nColl.OrderedItems { + posts = posts + 1 + if len(e.Attachment) > 0 { + imgs = imgs + 1 + } + } + + return posts, imgs } func GetObjectAttachment(db *sql.DB, id string) []ObjectBase { diff --git a/config-init b/config-init index 2299ea8..f8173ea 100644 --- a/config-init +++ b/config-init @@ -3,8 +3,15 @@ instancetp:https:// instanceport:3000 instancename:FChan instancesummary:FChan is a federated image board instance. + dbhost:localhost dbport:5432 dbname:fchan_server dbuser:postgres dbpass:password + +emailserver: +emailport +emailaddress: +emailpass: + @@ -26,10 +26,10 @@ var authReq = []string{"captcha","email","passphrase"} var supportedFiles = []string{"image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/avif","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav", "audio/wave", "audio/x-wav"} -var SiteEmail string //contact@fchan.xyz -var SiteEmailPassword string -var SiteEmailServer string //mail.fchan.xyz -var SiteEmailPort string //587 +var SiteEmail = GetConfigValue("emailaddress") //contact@fchan.xyz +var SiteEmailPassword = GetConfigValue("emailpass") +var SiteEmailServer = GetConfigValue("emailserver") //mail.fchan.xyz +var SiteEmailPort = GetConfigValue("emailport") //587 type BoardAccess struct { boards []string @@ -104,7 +104,6 @@ func main() { } } - if mainActor { GetActorInfo(w, db, Domain) } else if mainInbox { |