mirror of https://gitlab.com/ngerakines/tavern.git
Applying uniform UTC references in time creation and parsing. Closes #41
This commit is contained in:
parent
18c0270ef9
commit
6187aa0cec
|
@ -116,7 +116,7 @@ func (s pgStorage) GetLogger() *zap.Logger {
|
|||
}
|
||||
|
||||
func (s pgStorage) RowCount(ctx context.Context, query string, args ...interface{}) (int, error) {
|
||||
return s.rowCount(s.db, ctx, query, args...)
|
||||
return s.wrappedRowCount(errors.WrapQueryFailedError, s.db, ctx, query, args...)
|
||||
}
|
||||
|
||||
func (s pgStorage) rowCount(qec QueryExecute, ctx context.Context, query string, args ...interface{}) (int, error) {
|
||||
|
@ -139,7 +139,6 @@ func (s pgStorage) wrappedExists(ew errors.ErrorWrapper, ctx context.Context, qu
|
|||
s.logger.Debug("row count query", zap.String("query", query), zap.Reflect("args", args))
|
||||
|
||||
var total int
|
||||
|
||||
err := s.db.QueryRowContext(ctx, query, args...).Scan(&total)
|
||||
if err != nil {
|
||||
return false, ew(err)
|
||||
|
|
|
@ -224,7 +224,7 @@ func (h handler) actorInboxFollow(c *gin.Context, user *storage.User, payload st
|
|||
response["object"] = payload
|
||||
response["to"] = followerActor.GetID()
|
||||
response["type"] = "Accept"
|
||||
response["published"] = time.Now().Format("2006-01-02T15:04:05Z")
|
||||
response["published"] = time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
responsePayload := response.Bytes()
|
||||
|
||||
nc := fed.ActorClient{
|
||||
|
@ -560,7 +560,7 @@ func (h handler) actorInboxDelete(c *gin.Context, user *storage.User, payload st
|
|||
// TODO: Ensure that the object is, in fact, a note.
|
||||
tombstone["formerType"] = "Note"
|
||||
tombstone["id"] = objectID
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
deletedAt := now.Format("2006-01-02T15:04:05Z")
|
||||
tombstone["deleted"] = deletedAt
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ func (h handler) createNote(c *gin.Context) {
|
|||
errorPage = errorPage + "?advanced=true"
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
|
||||
activityID := storage.NewV4()
|
||||
|
||||
|
@ -498,7 +498,7 @@ func (h handler) announceNote(c *gin.Context) {
|
|||
}
|
||||
|
||||
actor := storage.NewActorID(user.Name, h.domain)
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
publishedAt := now.Format("2006-01-02T15:04:05Z")
|
||||
|
||||
to := []string{
|
||||
|
@ -703,7 +703,7 @@ func (h handler) deleteNote(c *gin.Context) {
|
|||
|
||||
objectID := c.PostForm("object_id")
|
||||
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
deletedAt := now.Format("2006-01-02T15:04:05Z")
|
||||
|
||||
tombstone := storage.EmptyPayload()
|
||||
|
|
|
@ -296,7 +296,7 @@ func (h handler) displayObjectFeed(c *gin.Context, requireUser bool, vars map[st
|
|||
|
||||
if published, hasPublished := storage.JSONString(objectPayload, "published"); hasPublished {
|
||||
var publishedAt time.Time
|
||||
publishedAt, err := time.Parse("2006-01-02T15:04:05Z", published)
|
||||
publishedAt, err := time.ParseInLocation("2006-01-02T15:04:05Z", published, time.UTC)
|
||||
if err == nil {
|
||||
viewContext.HasPublishedAt = true
|
||||
viewContext.PublishedAt = publishedAt
|
||||
|
|
|
@ -138,7 +138,7 @@ func (h handler) networkFollow(c *gin.Context) {
|
|||
follow["object"] = actor.GetID()
|
||||
follow["to"] = actor.GetID()
|
||||
follow["type"] = "Follow"
|
||||
follow["published"] = time.Now().Format("2006-01-02T15:04:05Z")
|
||||
follow["published"] = time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
|
||||
payload := follow.Bytes()
|
||||
|
||||
|
@ -213,7 +213,7 @@ func (h handler) networkUnfollow(c *gin.Context) {
|
|||
undoFollow["object"] = requestActivity
|
||||
undoFollow["to"] = to
|
||||
undoFollow["type"] = "Undo"
|
||||
undoFollow["published"] = time.Now().Format("2006-01-02T15:04:05Z")
|
||||
undoFollow["published"] = time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
|
||||
payload := undoFollow.Bytes()
|
||||
|
||||
|
@ -288,7 +288,7 @@ func (h handler) networkAccept(c *gin.Context) {
|
|||
response["object"] = activity
|
||||
response["to"] = followerActor.GetID()
|
||||
response["type"] = "Accept"
|
||||
response["published"] = time.Now().Format("2006-01-02T15:04:05Z")
|
||||
response["published"] = time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
responsePayload := response.Bytes()
|
||||
|
||||
nc := fed.ActorClient{
|
||||
|
@ -356,7 +356,7 @@ func (h handler) networkReject(c *gin.Context) {
|
|||
response["object"] = activity
|
||||
response["to"] = followerActor.GetID()
|
||||
response["type"] = "Reject"
|
||||
response["published"] = time.Now().Format("2006-01-02T15:04:05Z")
|
||||
response["published"] = time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
responsePayload := response.Bytes()
|
||||
|
||||
err = h.storage.RemoveFollower(ctx, user.ID, followerActor.ID)
|
||||
|
|
|
@ -303,7 +303,7 @@ func (h handler) viewObject(c *gin.Context) {
|
|||
|
||||
if published, hasPublished := storage.JSONString(objectPayload, "published"); hasPublished {
|
||||
var publishedAt time.Time
|
||||
publishedAt, err := time.Parse("2006-01-02T15:04:05Z", published)
|
||||
publishedAt, err := time.ParseInLocation("2006-01-02T15:04:05Z", published, time.UTC)
|
||||
if err == nil {
|
||||
viewContext.HasPublishedAt = true
|
||||
viewContext.PublishedAt = publishedAt
|
||||
|
|
|
@ -103,7 +103,7 @@ func (v *viewFeed) tombstoneView(orig storage.Payload) (string, map[string]inter
|
|||
|
||||
if deleted, hasDeleted := storage.JSONString(p, "deleted"); hasDeleted {
|
||||
var deletedAt time.Time
|
||||
deletedAt, err := time.Parse("2006-01-02T15:04:05Z", deleted)
|
||||
deletedAt, err := time.ParseInLocation("2006-01-02T15:04:05Z", deleted, time.UTC)
|
||||
if err != nil {
|
||||
deletedAt = time.Now()
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ func (v *viewFeed) createNoteViewFromPayload(orig storage.Payload) (string, map[
|
|||
|
||||
if published, hasPublished := storage.JSONString(p, "published"); hasPublished {
|
||||
var publishedAt time.Time
|
||||
publishedAt, err := time.Parse("2006-01-02T15:04:05Z", published)
|
||||
publishedAt, err := time.ParseInLocation("2006-01-02T15:04:05Z", published, time.UTC)
|
||||
if err != nil {
|
||||
publishedAt = time.Now()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue