Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Timestamp fixes #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/persistence/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ConversationName(metadata *proto.ConversationMetadata) string {

func MessageName(date time.Time, sender string) string {
//messageName := "date-sender"
dateStr := date.UTC().Format(time.RFC3339)
dateStr := date.UTC().Format(time.RFC3339Nano)
return fmt.Sprintf("%s-%s", dateStr, sender)
}

Expand Down Expand Up @@ -181,10 +181,10 @@ type Message struct {

func ReadMessageFromFile(path string) (*Message, error) {
base := filepath.Base(path)
if len(base) < len("2015-02-16T07:09:55Z-") {
if len(base) < len("2006-01-02T15:04:05.999999999Z-") {
return nil, fmt.Errorf("badly formatted message filename : " + path)
}
sender := base[len("2015-02-16T07:09:55Z-"):]
sender := base[len("2006-01-02T15:04:05.999999999Z-"):]
contents, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("badly formatted message filename : " + path)
Expand Down
9 changes: 4 additions & 5 deletions client/readloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"github.com/andres-erbsen/chatterbox/transport"
)


type EnvelopeWithId struct {
Envelope []byte
Id *[32]byte
Id *[32]byte
}

type ConnectionToServer struct {
Expand Down Expand Up @@ -41,9 +40,9 @@ func (c *ConnectionToServer) ReceiveMessages() error {
}
}
if msg.Envelope != nil {
envwithid := &EnvelopeWithId {
Envelope : msg.Envelope,
Id : (*[32]byte) (msg.MessageId),
envwithid := &EnvelopeWithId{
Envelope: msg.Envelope,
Id: (*[32]byte)(msg.MessageId),
}
go func() { c.ReadEnvelope <- envwithid }() // TODO: bounded buffer?
} else {
Expand Down
1 change: 1 addition & 0 deletions proto/proto_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func ToProtoByte32List(list []*[32]byte) []Byte32 {
return newList
}

//returns a slice of COPIES of the original message list
func To32ByteList(list []Byte32) []*[32]byte {
newList := make([]*[32]byte, 0, 0)
for _, element := range list {
Expand Down