3
0

Fix attachment issues on cmp&msg

This commit is contained in:
Denis Arh 2020-12-18 10:42:53 +01:00
parent fb32fa151c
commit 8fa00d04d7
2 changed files with 7 additions and 4 deletions

View File

@ -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()

View File

@ -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")
}