MM-46410: adds urgency on mention counts (#20999)

* 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 a column, urgentmentioncount, in channelmembers.
Furthermore when asking for team/thread mention counts, we also return
urgent mention counts for the user.

Adds a new table to hold posts priorities
Refactors priority out of the props and into the new table

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.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Vishal Choudhary <vish9812@gmail.com>
Этот коммит содержится в:
Kyriakos Z
2022-11-23 21:08:21 +02:00
коммит произвёл GitHub
родитель ff1ea0599e
Коммит c44d37629a
47 изменённых файлов: 1676 добавлений и 343 удалений

Просмотреть файл

@@ -192,6 +192,8 @@ db/migrations/mysql/000095_remove_posts_parentid.down.sql
db/migrations/mysql/000095_remove_posts_parentid.up.sql
db/migrations/mysql/000096_threads_threadteamid.down.sql
db/migrations/mysql/000096_threads_threadteamid.up.sql
db/migrations/mysql/000097_create_posts_priority.down.sql
db/migrations/mysql/000097_create_posts_priority.up.sql
db/migrations/postgres/000001_create_teams.down.sql
db/migrations/postgres/000001_create_teams.up.sql
db/migrations/postgres/000002_create_team_members.down.sql
@@ -384,3 +386,5 @@ db/migrations/postgres/000095_remove_posts_parentid.down.sql
db/migrations/postgres/000095_remove_posts_parentid.up.sql
db/migrations/postgres/000096_threads_threadteamid.down.sql
db/migrations/postgres/000096_threads_threadteamid.up.sql
db/migrations/postgres/000097_create_posts_priority.down.sql
db/migrations/postgres/000097_create_posts_priority.up.sql

Просмотреть файл

@@ -0,0 +1,16 @@
DROP TABLE IF EXISTS PostsPriority;
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'ChannelMembers'
AND table_schema = DATABASE()
AND column_name = 'UrgentMentionCount'
) > 0,
'ALTER TABLE ChannelMembers DROP COLUMN UrgentMentionCount;',
'SELECT 1'
));
PREPARE alterIfExists FROM @preparedStatement;
EXECUTE alterIfExists;
DEALLOCATE PREPARE alterIfExists;

Просмотреть файл

@@ -0,0 +1,23 @@
CREATE TABLE IF NOT EXISTS PostsPriority (
PostId varchar(26) NOT NULL,
ChannelId varchar(26) NOT NULL,
Priority varchar(32) NOT NULL,
RequestedAck tinyint(1),
PersistentNotifications tinyint(1),
PRIMARY KEY (PostId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SET @preparedStatement = (SELECT IF(
NOT EXISTS(
SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'ChannelMembers'
AND table_schema = DATABASE()
AND column_name = 'UrgentMentionCount'
),
'ALTER TABLE ChannelMembers ADD COLUMN UrgentMentionCount bigint(20);',
'SELECT 1;'
));
PREPARE alterIfNotExists FROM @preparedStatement;
EXECUTE alterIfNotExists;
DEALLOCATE PREPARE alterIfNotExists;

Просмотреть файл

@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS postspriority;
ALTER TABLE channelmembers DROP COLUMN IF EXISTS urgentmentioncount;

Просмотреть файл

@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS postspriority (
postid VARCHAR(26) PRIMARY KEY,
channelid VARCHAR(26) NOT NULL,
priority VARCHAR(32) NOT NULL,
requestedack boolean,
persistentnotifications boolean
);
ALTER TABLE channelmembers ADD COLUMN IF NOT EXISTS urgentmentioncount bigint;