received timestamp added to bd
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -173,6 +173,14 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
|
|||||||
// user message
|
// user message
|
||||||
|
|
||||||
messagesOverview = append(messagesOverview, peer.Name+" > "+string(usermsg.Data))
|
messagesOverview = append(messagesOverview, peer.Name+" > "+string(usermsg.Data))
|
||||||
|
|
||||||
|
// stamp the received time before storing
|
||||||
|
receivedAt := time.Now().UTC().Unix()
|
||||||
|
if usermsg.Status == nil {
|
||||||
|
usermsg.Status = &meowlib.ConversationStatus{}
|
||||||
|
}
|
||||||
|
usermsg.Status.Received = uint64(receivedAt)
|
||||||
|
|
||||||
// add message to storage
|
// add message to storage
|
||||||
err = peer.StoreMessage(usermsg, filenames)
|
err = peer.StoreMessage(usermsg, filenames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -181,9 +189,9 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
|
|||||||
filenames = []string{}
|
filenames = []string{}
|
||||||
|
|
||||||
// Send delivery ack if the peer requested it
|
// Send delivery ack if the peer requested it
|
||||||
if peer.SendDeliveryAck && usermsg.Status != nil && usermsg.Status.Uuid != "" {
|
if peer.SendDeliveryAck && usermsg.Status.Uuid != "" {
|
||||||
storagePath := filepath.Join(client.GetConfig().StoragePath, identity.Uuid)
|
storagePath := filepath.Join(client.GetConfig().StoragePath, identity.Uuid)
|
||||||
if ackErr := sendDeliveryAck(storagePath, peer, usermsg.Status.Uuid); ackErr != nil {
|
if ackErr := sendDeliveryAck(storagePath, peer, usermsg.Status.Uuid, receivedAt); ackErr != nil {
|
||||||
logger.Warn().Err(ackErr).Str("peer", peer.Uid).Msg("ConsumeInboxFile: sendDeliveryAck")
|
logger.Warn().Err(ackErr).Str("peer", peer.Uid).Msg("ConsumeInboxFile: sendDeliveryAck")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,8 +259,8 @@ func LongPollAllServerJobs(storage_path string, jobs []client.RequestsJob, timeo
|
|||||||
|
|
||||||
// sendDeliveryAck builds a delivery acknowledgment for messageUuid and enqueues
|
// sendDeliveryAck builds a delivery acknowledgment for messageUuid and enqueues
|
||||||
// it for sending to the peer's contact pull servers.
|
// it for sending to the peer's contact pull servers.
|
||||||
func sendDeliveryAck(storagePath string, peer *client.Peer, messageUuid string) error {
|
func sendDeliveryAck(storagePath string, peer *client.Peer, messageUuid string, receivedAt int64) error {
|
||||||
packedMsg, _, err := BuildReceivedMessage(messageUuid, peer.Uid, time.Now().UTC().Unix())
|
packedMsg, _, err := BuildReceivedMessage(messageUuid, peer.Uid, receivedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("sendDeliveryAck: BuildReceivedMessage: %w", err)
|
return fmt.Errorf("sendDeliveryAck: BuildReceivedMessage: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user