received timestamp added to bd
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2026-03-04 11:58:14 +01:00
parent 14a07dcb5c
commit 5748ead926

View File

@@ -173,6 +173,14 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
// user message
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
err = peer.StoreMessage(usermsg, filenames)
if err != nil {
@@ -180,13 +188,13 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
}
filenames = []string{}
// Send delivery ack if the peer requested it
if peer.SendDeliveryAck && usermsg.Status != nil && usermsg.Status.Uuid != "" {
storagePath := filepath.Join(client.GetConfig().StoragePath, identity.Uuid)
if ackErr := sendDeliveryAck(storagePath, peer, usermsg.Status.Uuid); ackErr != nil {
logger.Warn().Err(ackErr).Str("peer", peer.Uid).Msg("ConsumeInboxFile: sendDeliveryAck")
// Send delivery ack if the peer requested it
if peer.SendDeliveryAck && usermsg.Status.Uuid != "" {
storagePath := filepath.Join(client.GetConfig().StoragePath, identity.Uuid)
if ackErr := sendDeliveryAck(storagePath, peer, usermsg.Status.Uuid, receivedAt); ackErr != nil {
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
// it for sending to the peer's contact pull servers.
func sendDeliveryAck(storagePath string, peer *client.Peer, messageUuid string) error {
packedMsg, _, err := BuildReceivedMessage(messageUuid, peer.Uid, time.Now().UTC().Unix())
func sendDeliveryAck(storagePath string, peer *client.Peer, messageUuid string, receivedAt int64) error {
packedMsg, _, err := BuildReceivedMessage(messageUuid, peer.Uid, receivedAt)
if err != nil {
return fmt.Errorf("sendDeliveryAck: BuildReceivedMessage: %w", err)
}