aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-17 12:21:36 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-17 12:21:36 +0200
commite42a7725724eb3c28d95254fefcce94cce26d399 (patch)
treebbb02eb0380e44a160aa3e02bd4715eaca0c67cb
parent9d0bacf367679c97d14a5a926da2a6491c27bc83 (diff)
Fix message timestamps
-rw-r--r--matrix.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/matrix.go b/matrix.go
index d611bb0..f578ac3 100644
--- a/matrix.go
+++ b/matrix.go
@@ -17,7 +17,6 @@
package main
import (
- "encoding/json"
"fmt"
"strings"
"time"
@@ -153,11 +152,9 @@ func (c *MatrixContainer) Start() {
func (c *MatrixContainer) HandleMessage(evt *gomatrix.Event) {
message, _ := evt.Content["body"].(string)
- timestampNumber, _ := evt.Content["origin_server_ts"].(json.Number)
- timestampInt64, _ := timestampNumber.Int64()
timestamp := time.Now()
- if timestampInt64 != 0 {
- timestamp = time.Unix(timestampInt64/1000, timestampInt64%1000*1000)
+ if evt.Timestamp != 0 {
+ timestamp = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000)
}
c.ui.MainView().AddRealMessage(evt.RoomID, evt.ID, evt.Sender, message, timestamp)