* MM-46410: adds urgency on mention counts We have introduced priority for posts in https://github.com/mattermost/mattermost-webapp/pull/10951. We do need to color the mention badges in the webapp with a prominent color when a mention is posted in an urgent message. A thread has urgent mentions if the root post is marked as urgent, and the replies contain mentions to the user viewing the thread. This PR adds two columns, urgentmentioncount, and isurgent, in channelmembers, and threads tables respectively. Furthermore when asking for team/thread mention counts, we also return urgent mention counts for the user. * Fixes method in tests * empty commit * Fixes method call * Fixes single thread response is_urgent * Fixes errors * Fixes mysql migration and adds graphql schema * Fixes tests * Refactors IsUrgent and Adds PostsPriority table Changes: - removes is_urgent from the threads table - adds a new table to hold posts priorities - refactors priority out of the props and into the new table * Fixes * Adds translation strings * Fixes migrations and tests * Fixes tests * empty * Adds Priority to Copy * empty * Fixes priority not saved when boards is enabled We are nilifying Metadata when post.ForPlugin(), which didn't save Priority for a post when Boards was enabled. This commit copies metadata again to the post, so metadata are reinstated. * Fixes tests * Adding store tests and fixes syntax error * Uses threads.ThreadTeamId * Fixes error * Adds UrgentMentionCount in graphql api test * Fetches post priority in batches * Addresses review comments * Restore only priority on create post * Fixes tests * Nits * Some refactoring * Fixes get thread options when post priority enabled * Adds missing translation * Use the constant instead of "urgent" string * Renames urgent constant * MM-47750: Adds PostAcknowledgements table and apis - Adds post acknowledgement api/app/store methods to be able to save and delete post acknowledgements by users. - Adds wesbsocket events for acknowledgement created/deleted - Returns post acknowledgements in the post's metadata * Empty * Fixes incorrect urgent count when marking a post as unread * Adds license * Fixes ACK api, and adds tests * Fixes vet * Fixes tests * Addresses review comments * Remove unnecessary lines * Adds config option and changes return of delete ack * Empty * Empty * Enable config by default * Fixes intl * Fixes test after setting config default true * Changes endpoints to PostForUser * Avoids replica lag * Fixes error in merge * Fixes RetryLayer tests due to merge * Empty * Empty * Empty Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
87 строки
3.0 KiB
Go
87 строки
3.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
type PostMetadata struct {
|
|
// Embeds holds information required to render content embedded in the post. This includes the OpenGraph metadata
|
|
// for links in the post.
|
|
Embeds []*PostEmbed `json:"embeds,omitempty"`
|
|
|
|
// Emojis holds all custom emojis used in the post or used in reaction to the post.
|
|
Emojis []*Emoji `json:"emojis,omitempty"`
|
|
|
|
// Files holds information about the file attachments on the post.
|
|
Files []*FileInfo `json:"files,omitempty"`
|
|
|
|
// Images holds the dimensions of all external images in the post as a map of the image URL to its dimensions.
|
|
// This includes image embeds (when the message contains a plaintext link to an image), Markdown images, images
|
|
// contained in the OpenGraph metadata, and images contained in message attachments. It does not contain
|
|
// the dimensions of any file attachments as those are stored in FileInfos.
|
|
Images map[string]*PostImage `json:"images,omitempty"`
|
|
|
|
// Reactions holds reactions made to the post.
|
|
Reactions []*Reaction `json:"reactions,omitempty"`
|
|
|
|
// Priority holds info about priority settings for the post.
|
|
Priority *PostPriority `json:"priority,omitempty"`
|
|
|
|
// Acknowledgements holds acknowledgements made by users to the post
|
|
Acknowledgements []*PostAcknowledgement `json:"acknowledgements,omitempty"`
|
|
}
|
|
|
|
type PostImage struct {
|
|
Width int `json:"width"`
|
|
Height int `json:"height"`
|
|
|
|
// Format is the name of the image format as used by image/go such as "png", "gif", or "jpeg".
|
|
Format string `json:"format"`
|
|
|
|
// FrameCount stores the number of frames in this image, if it is an animated gif. It will be 0 for other formats.
|
|
FrameCount int `json:"frame_count"`
|
|
}
|
|
|
|
// Copy does a deep copy
|
|
func (p *PostMetadata) Copy() *PostMetadata {
|
|
embedsCopy := make([]*PostEmbed, len(p.Embeds))
|
|
copy(embedsCopy, p.Embeds)
|
|
|
|
emojisCopy := make([]*Emoji, len(p.Emojis))
|
|
copy(emojisCopy, p.Emojis)
|
|
|
|
filesCopy := make([]*FileInfo, len(p.Files))
|
|
copy(filesCopy, p.Files)
|
|
|
|
imagesCopy := map[string]*PostImage{}
|
|
for k, v := range p.Images {
|
|
imagesCopy[k] = v
|
|
}
|
|
|
|
reactionsCopy := make([]*Reaction, len(p.Reactions))
|
|
copy(reactionsCopy, p.Reactions)
|
|
|
|
acknowledgementsCopy := make([]*PostAcknowledgement, len(p.Acknowledgements))
|
|
copy(acknowledgementsCopy, p.Acknowledgements)
|
|
|
|
var postPriorityCopy *PostPriority
|
|
if p.Priority != nil {
|
|
postPriorityCopy = &PostPriority{
|
|
Priority: p.Priority.Priority,
|
|
RequestedAck: p.Priority.RequestedAck,
|
|
PersistentNotifications: p.Priority.PersistentNotifications,
|
|
PostId: p.Priority.PostId,
|
|
ChannelId: p.Priority.ChannelId,
|
|
}
|
|
}
|
|
|
|
return &PostMetadata{
|
|
Embeds: embedsCopy,
|
|
Emojis: emojisCopy,
|
|
Files: filesCopy,
|
|
Images: imagesCopy,
|
|
Reactions: reactionsCopy,
|
|
Priority: postPriorityCopy,
|
|
Acknowledgements: acknowledgementsCopy,
|
|
}
|
|
}
|