Fix message timestamps

This commit is contained in:
Tulir Asokan 2018-03-17 12:21:36 +02:00
parent 9d0bacf367
commit e42a772572

View File

@ -17,7 +17,6 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"strings" "strings"
"time" "time"
@ -153,11 +152,9 @@ func (c *MatrixContainer) Start() {
func (c *MatrixContainer) HandleMessage(evt *gomatrix.Event) { func (c *MatrixContainer) HandleMessage(evt *gomatrix.Event) {
message, _ := evt.Content["body"].(string) message, _ := evt.Content["body"].(string)
timestampNumber, _ := evt.Content["origin_server_ts"].(json.Number)
timestampInt64, _ := timestampNumber.Int64()
timestamp := time.Now() timestamp := time.Now()
if timestampInt64 != 0 { if evt.Timestamp != 0 {
timestamp = time.Unix(timestampInt64/1000, timestampInt64%1000*1000) timestamp = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000)
} }
c.ui.MainView().AddRealMessage(evt.RoomID, evt.ID, evt.Sender, message, timestamp) c.ui.MainView().AddRealMessage(evt.RoomID, evt.ID, evt.Sender, message, timestamp)