diff options
author | FChannel <> | 2021-07-07 13:48:22 -0700 |
---|---|---|
committer | FChannel <> | 2021-07-07 13:48:22 -0700 |
commit | 3d6891c9403bbc3c7d268c17b5e514bb38eb2881 (patch) | |
tree | b6cfb3282d149618b7c33d053ba13d3bd99cc998 /cacheDatabase.go | |
parent | 188c137e8ffee7fce6cb5e363b5ea5a3095318ef (diff) |
fixed caching order
Diffstat (limited to 'cacheDatabase.go')
-rw-r--r-- | cacheDatabase.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/cacheDatabase.go b/cacheDatabase.go index 22a4a79..7ab3b9e 100644 --- a/cacheDatabase.go +++ b/cacheDatabase.go @@ -79,11 +79,15 @@ func WriteActivitytoCache(db *sql.DB, obj ObjectBase) { if id != "" { return - } + } + + if obj.Updated == "" { + obj.Updated = obj.Published + } query = `insert into cacheactivitystream (id, type, name, content, published, updated, attributedto, actor, tripcode, sensitive) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Published, obj.AttributedTo, obj.Actor, obj.TripCode, obj.Sensitive) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity cache") @@ -110,11 +114,15 @@ func WriteActivitytoCacheWithAttachment(db *sql.DB, obj ObjectBase, attachment O if id != "" { return - } + } + + if obj.Updated == "" { + obj.Updated = obj.Published + } query = `insert into cacheactivitystream (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)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Published, obj.AttributedTo, obj.Actor, obj.TripCode, obj.Sensitive) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, preview.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor, obj.TripCode, obj.Sensitive) if e != nil{ fmt.Println("error inserting new activity with attachment cache") @@ -138,10 +146,14 @@ func WriteAttachmentToCache(db *sql.DB, obj ObjectBase) { if id != "" { return } + + if obj.Updated == "" { + obj.Updated = obj.Published + } query = `insert into cacheactivitystream (id, type, name, href, published, updated, attributedTo, mediatype, size) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Href, obj.Published, obj.Published, obj.AttributedTo, obj.MediaType, obj.Size) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Href, obj.Published, obj.Updated, obj.AttributedTo, obj.MediaType, obj.Size) if e != nil{ fmt.Println("error inserting new attachment cache") @@ -164,11 +176,15 @@ func WritePreviewToCache(db *sql.DB, obj NestedObjectBase) { if id != "" { return + } + + if obj.Updated == "" { + obj.Updated = obj.Published } query = `insert into cacheactivitystream (id, type, name, href, published, updated, attributedTo, mediatype, size) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)` - _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Href, obj.Published, obj.Published, obj.AttributedTo, obj.MediaType, obj.Size) + _, e := db.Exec(query, obj.Id ,obj.Type, obj.Name, obj.Href, obj.Published, obj.Updated, obj.AttributedTo, obj.MediaType, obj.Size) if e != nil{ fmt.Println("error inserting new preview cache") |