diff --git a/compose/service/attachment.go b/compose/service/attachment.go index 3f0a3acd1..99d2fb041 100644 --- a/compose/service/attachment.go +++ b/compose/service/attachment.go @@ -348,6 +348,7 @@ func (svc attachment) create(name string, size int64, fh io.ReadSeeker, att *typ // preset attachment ID because we need ref for storage att.ID = nextID() + att.CreatedAt = *now() if att.OwnerID == 0 { att.OwnerID = auth.GetIdentityFromContext(svc.ctx).Identity() diff --git a/messaging/service/attachment.go b/messaging/service/attachment.go index 3a6aff74a..4b092612a 100644 --- a/messaging/service/attachment.go +++ b/messaging/service/attachment.go @@ -116,10 +116,8 @@ func (svc attachment) CreateMessageAttachment(name string, size int64, fh io.Rea } att = &types.Attachment{ - ID: nextID(), - OwnerID: currentUserID, - Name: strings.TrimSpace(name), - CreatedAt: *now(), + OwnerID: currentUserID, + Name: strings.TrimSpace(name), } err = svc.create(name, size, fh, att) @@ -139,6 +137,7 @@ func (svc attachment) CreateMessageAttachment(name string, size int64, fh io.Rea ChannelID: channelID, ReplyTo: replyTo, UserID: currentUserID, + CreatedAt: *now(), } if strings.HasPrefix(att.Meta.Original.Mimetype, "image/") { @@ -169,6 +168,9 @@ func (svc attachment) create(name string, size int64, fh io.ReadSeeker, att *typ aProps = &attachmentActionProps{} ) + att.ID = nextID() + att.CreatedAt = *now() + if svc.files == nil { return fmt.Errorf("can not create attachment: store handler not set") }