mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
Added the bot-notification changes for attachment (#4301)
* Added the bot-notification changes for attachment * Linter fixes * Added Todo for i18n * Grammer fix * Statement Corrections * Grammer fix --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
1b917ba44d
commit
cc9a689c8b
@ -189,6 +189,9 @@ func cardDiff2SlackAttachment(cardDiff *Diff, opts DiffConvOpts) (*mm_model.Slac
|
||||
// comment add/delete
|
||||
attachment.Fields = appendCommentChanges(attachment.Fields, cardDiff)
|
||||
|
||||
// File Attachment add/delete
|
||||
attachment.Fields = appendAttachmentChanges(attachment.Fields, cardDiff)
|
||||
|
||||
// content/description changes
|
||||
attachment.Fields = appendContentChanges(attachment.Fields, cardDiff, opts.Logger)
|
||||
|
||||
@ -264,6 +267,31 @@ func appendCommentChanges(fields []*mm_model.SlackAttachmentField, cardDiff *Dif
|
||||
return fields
|
||||
}
|
||||
|
||||
func appendAttachmentChanges(fields []*mm_model.SlackAttachmentField, cardDiff *Diff) []*mm_model.SlackAttachmentField {
|
||||
for _, child := range cardDiff.Diffs {
|
||||
if child.BlockType == model.TypeAttachment {
|
||||
var format string
|
||||
var msg string
|
||||
if child.NewBlock != nil && child.OldBlock == nil {
|
||||
format = "Added an attachment: **`%s`**"
|
||||
msg = child.NewBlock.Title
|
||||
} else {
|
||||
format = "Removed ~~`%s`~~ attachment"
|
||||
msg = stripNewlines(child.OldBlock.Title)
|
||||
}
|
||||
|
||||
if format != "" {
|
||||
fields = append(fields, &mm_model.SlackAttachmentField{
|
||||
Short: false,
|
||||
Title: "Changed by " + makeAuthorsList(child.Authors, "unknown_user"), // TODO: localize this when server has i18n
|
||||
Value: fmt.Sprintf(format, msg),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
func appendContentChanges(fields []*mm_model.SlackAttachmentField, cardDiff *Diff, logger mlog.LoggerIFace) []*mm_model.SlackAttachmentField {
|
||||
for _, child := range cardDiff.Diffs {
|
||||
var opAdd, opDelete bool
|
||||
|
@ -182,6 +182,7 @@ const CardDialog = (props: Props): JSX.Element => {
|
||||
removeUploadingAttachment(uploadingBlock)
|
||||
const block = createAttachmentBlock()
|
||||
block.fields.attachmentId = attachmentId || ''
|
||||
block.title = attachment.name
|
||||
sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.uploadSuccess', defaultMessage: 'Attachment uploaded successfull.'}), severity: 'normal'})
|
||||
resolve(block)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user