diff options
author | FChannel <> | 2021-06-28 15:22:45 -0700 |
---|---|---|
committer | FChannel <> | 2021-06-28 15:22:45 -0700 |
commit | 3f253bd03c663366a68b93b3e9a12b41902a8a09 (patch) | |
tree | 29c1e01b027262ffd39ebd433576def31e955a6b | |
parent | ac7fd1f68d396cb676a9a111bddae7e36302b4c6 (diff) |
changed all time to UTC to sync better regardless of server timeformat
-rw-r--r-- | database.go | 34 | ||||
-rw-r--r-- | main.go | 14 | ||||
-rw-r--r-- | static/faq.html | 2 | ||||
-rw-r--r-- | verification.go | 6 |
4 files changed, 28 insertions, 28 deletions
diff --git a/database.go b/database.go index e88dd1e..9d5d721 100644 --- a/database.go +++ b/database.go @@ -163,16 +163,16 @@ func WriteObjectToDB(db *sql.DB, obj ObjectBase) ObjectBase { if len(obj.Attachment) > 0 { if obj.Preview.Href != "" { obj.Preview.Id = fmt.Sprintf("%s/%s", obj.Actor, CreateUniqueID(db, obj.Actor)) - obj.Preview.Published = time.Now().Format(time.RFC3339) - obj.Preview.Updated = time.Now().Format(time.RFC3339) + obj.Preview.Published = time.Now().UTC().Format(time.RFC3339) + obj.Preview.Updated = time.Now().UTC().Format(time.RFC3339) obj.Preview.AttributedTo = obj.Id WritePreviewToDB(db, *obj.Preview) } for i, _ := range obj.Attachment { obj.Attachment[i].Id = fmt.Sprintf("%s/%s", obj.Actor, CreateUniqueID(db, obj.Actor)) - obj.Attachment[i].Published = time.Now().Format(time.RFC3339) - obj.Attachment[i].Updated = time.Now().Format(time.RFC3339) + obj.Attachment[i].Published = time.Now().UTC().Format(time.RFC3339) + obj.Attachment[i].Updated = time.Now().UTC().Format(time.RFC3339) obj.Attachment[i].AttributedTo = obj.Id WriteAttachmentToDB(db, obj.Attachment[i]) WriteActivitytoDBWithAttachment(db, obj, obj.Attachment[i], *obj.Preview) @@ -191,7 +191,7 @@ func WriteObjectToDB(db *sql.DB, obj ObjectBase) ObjectBase { func WriteObjectUpdatesToDB(db *sql.DB, obj ObjectBase) { query := `update activitystream set updated=$1 where id=$2` - _, e := db.Exec(query, time.Now().Format(time.RFC3339), obj.Id) + _, e := db.Exec(query, time.Now().UTC().Format(time.RFC3339), obj.Id) if e != nil{ fmt.Println("error inserting updating inreplyto") @@ -200,7 +200,7 @@ func WriteObjectUpdatesToDB(db *sql.DB, obj ObjectBase) { query = `update cacheactivitystream set updated=$1 where id=$2` - _, e = db.Exec(query, time.Now().Format(time.RFC3339), obj.Id) + _, e = db.Exec(query, time.Now().UTC().Format(time.RFC3339), obj.Id) if e != nil{ fmt.Println("error inserting updating cache inreplyto") @@ -227,7 +227,7 @@ func WriteObjectReplyToLocalDB(db *sql.DB, id string, replyto string) { var val string rows.Scan(&val) if val == "" { - updated := time.Now().Format(time.RFC3339) + updated := time.Now().UTC().Format(time.RFC3339) query := `update activitystream set updated=$1 where id=$2` _, err := db.Exec(query, updated, replyto) @@ -1066,7 +1066,7 @@ func TombstoneAttachmentRepliesFromDB(db *sql.DB, id string) { } func TombstoneAttachmentFromDB(db *sql.DB, id string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', deleted=$2 where id in (select attachment from activitystream where id=$3)` @@ -1096,7 +1096,7 @@ func DeleteAttachmentFromDB(db *sql.DB, id string) { } func TombstonePreviewFromDB(db *sql.DB, id string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', deleted=$2 where id in (select preview from activitystream where id=$3)` @@ -1133,7 +1133,7 @@ func DeleteObjectRepliedTo(db *sql.DB, id string){ } func TombstoneObjectFromDB(db *sql.DB, id string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', name='', content='', attributedto='deleted', tripcode='', deleted=$1 where id=$2` _, err := db.Exec(query, datetime, id) @@ -1170,7 +1170,7 @@ func DeleteObjectsInReplyTo(db *sql.DB, id string) { } func TombstoneObjectRepliesFromDB(db *sql.DB, id string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', name='', content='', attributedto='deleted', tripcode='', deleted=$1 where id in (select id from replies where inreplyto=$2)` @@ -1185,7 +1185,7 @@ func TombstoneObjectRepliesFromDB(db *sql.DB, id string) { } func SetAttachmentFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id in (select attachment from activitystream where id=$3)` @@ -1201,7 +1201,7 @@ func SetAttachmentFromDB(db *sql.DB, id string, _type string) { } func SetAttachmentRepliesFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id in (select attachment from activitystream where id in (select id from replies where inreplyto=$3))` @@ -1217,7 +1217,7 @@ func SetAttachmentRepliesFromDB(db *sql.DB, id string, _type string) { } func SetPreviewFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id in (select preview from activitystream where id=$3)` @@ -1233,7 +1233,7 @@ func SetPreviewFromDB(db *sql.DB, id string, _type string) { } func SetPreviewRepliesFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id in (select preview from activitystream where id in (select id from replies where inreplyto=$3))` @@ -1249,7 +1249,7 @@ func SetPreviewRepliesFromDB(db *sql.DB, id string, _type string) { } func SetObjectFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id=$3` @@ -1265,7 +1265,7 @@ func SetObjectFromDB(db *sql.DB, id string, _type string) { } func SetObjectRepliesFromDB(db *sql.DB, id string, _type string) { - datetime := time.Now().Format(time.RFC3339) + datetime := time.Now().UTC().Format(time.RFC3339) var query = `update activitystream set type=$1, deleted=$2 where id in (select id from replies where inreplyto=$3)` _, err := db.Exec(query, _type, datetime, id) @@ -635,7 +635,7 @@ func main() { http.SetCookie(w, &http.Cookie{ Name: "session_token", Value: sessionToken.String(), - Expires: time.Now().Add(60 * 60 * 48 * time.Second), + Expires: time.Now().UTC().Add(60 * 60 * 48 * time.Second), }) http.Redirect(w, r, "/", http.StatusSeeOther) @@ -1224,7 +1224,7 @@ func GetContentType(location string) string { } func RandomID(size int) string { - rand.Seed(time.Now().UnixNano()) + rand.Seed(time.Now().UTC().UnixNano()) domain := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rng := size newID := "" @@ -1308,8 +1308,8 @@ func CreateObject(objType string) ObjectBase { var nObj ObjectBase nObj.Type = objType - nObj.Published = time.Now().Format(time.RFC3339) - nObj.Updated = time.Now().Format(time.RFC3339) + nObj.Published = time.Now().UTC().Format(time.RFC3339) + nObj.Updated = time.Now().UTC().Format(time.RFC3339) return nObj } @@ -1450,7 +1450,7 @@ func CreateAttachmentObject(file multipart.File, header *multipart.FileHeader) ( image.Href = Domain + "/" + tempFile.Name() image.MediaType = contentType image.Size = size - image.Published = time.Now().Format(time.RFC3339) + image.Published = time.Now().UTC().Format(time.RFC3339) nAttachment = append(nAttachment, image) @@ -1481,7 +1481,7 @@ func ParseCommentForReplies(comment string) []ObjectBase { if(isValid) { var reply = new(ObjectBase) reply.Id = links[i] - reply.Published = time.Now().Format(time.RFC3339) + reply.Published = time.Now().UTC().Format(time.RFC3339) validLinks = append(validLinks, *reply) } } @@ -2265,7 +2265,7 @@ func RouteProxy(req *http.Request) (*http.Response, error) { CheckError(err, "error parsing tor proxy url") proxyTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)} - client := &http.Client{ Transport: proxyTransport, Timeout: time.Second * 10 } + client := &http.Client{ Transport: proxyTransport, Timeout: time.Second * 75 } return client.Do(req) } diff --git a/static/faq.html b/static/faq.html index 8c7c4fe..12bf284 100644 --- a/static/faq.html +++ b/static/faq.html @@ -37,7 +37,7 @@ <p>coming soon(tm).</p> <h4>Server Version</h4> - <p>v0.0.1</p> + <p>v0.0.2</p> </div> <div style="width: 500px; margin:0 auto; margin-top: 50px; text-align: center;"> <a href="/">[Home]</a><a href="/static/rules.html">[Rules]</a><a href="/static/faq.html">[FAQ]</a> diff --git a/verification.go b/verification.go index 38c7bbe..c649a4e 100644 --- a/verification.go +++ b/verification.go @@ -138,7 +138,7 @@ func CreateBoardMod(db *sql.DB, verify Verify) { func CreateVerification(db *sql.DB, verify Verify) { query := `insert into verification (type, identifier, code, created) values ($1, $2, $3, $4)` - _, err := db.Exec(query, verify.Type, verify.Identifier, verify.Code, time.Now().Format(time.RFC3339)) + _, err := db.Exec(query, verify.Type, verify.Identifier, verify.Code, time.Now().UTC().Format(time.RFC3339)) CheckError(err, "error creating verify") } @@ -478,7 +478,7 @@ func BoardHasAuthType(db *sql.DB, board string, auth string) bool { } func Captcha() string { - rand.Seed(time.Now().UnixNano()) + rand.Seed(time.Now().UTC().UnixNano()) domain := "ABEFHKMNPQRSUVWXYZ#$&" rng := 4 newID := "" @@ -661,7 +661,7 @@ func VerifyHeaderSignature(r *http.Request, actor Actor) bool { t, _ := time.Parse(time.RFC1123, date) - if(time.Now().Sub(t).Seconds() > 75) { + if(time.Now().UTC().Sub(t).Seconds() > 75) { return false } |