Summary
Adds the ability to configure custom (granular) deletion policies for posts for specific teams and/or channels. When the daily retention job runs it selectively deletes posts by age based on the configuration.
...
Request:
Code Block |
---|
{ "team_id_ids": ["z7rxbxbfb7yxdydxzi8pestath"] } |
Response:
Code Block |
---|
{ "success_ids": ["z7rxbxbfb7yxdydxzi8pestath"], "failure_ids": [] } |
Because a teams can only be associated to a single granular retention policy, we must specify which teams failed.
...
DELETE /api/v4/retention_policies/:policy_id/teams/:team_id
removes a team from a retention policy.
...
Request:
Code Block |
---|
{ "channel_idids": ["z7rxbxbfb7yxdydxzi8pestath"] } |
Response:
Code Block |
---|
{ "success_ids": ["z7rxbxbfb7yxdydxzi8pestath"], "failure_ids": [] } |
Because a channel can only be associated to a single granular retention policy, we must specify which channels failed.
...
DELETE /api/v4/retention_policies/:policy_id/channels/:channel_id
deletes a channel from a retention policy.
...
Column name | Description |
---|---|
| varchar, the RetentionPolicies.Id foreign key |
| varchar, the Channels.Id foreign key |
TBD: Does ChannelId
need to be indexed?
RetentionPoliciesTeams
table
Column name | Description |
---|---|
| varchar, the RetentionPolicies.Id foreign key |
| varchar, the Teams.Id foreign key |
TBD: Does TeamId
need to be indexed?
Model
Rename
DataRetentionPolicy
toGlobalDataRetentionPolicy
Add
RetentionPolicy
representing a record in theRetentionPolicies
table.Add
RetentionPolicyChannel
representing a record in theRetentionPoliciesChannels
table.Add
RetentionPolicyTeam
representing a record in theRetentionPoliciesTeams
table.
...
Changes to various methods on DataRetentionWorker
in data_retention/worker.go
are required.
We need a new query to determine the Posts
records to be deleted. Something like this (untested):
Code Block | ||
---|---|---|
| ||
-- untested
SELECT
Posts.Id
FROM
Posts
JOIN Channels ON Channels.Id = Posts.ChannelId
JOIN Teams ON Teams.Id = Channels.TeamId
WHERE
(
Posts.CreateAt > @data_retention_channel1_timestamp
AND ChannelId = @data_retion_channel1_channel_id
)
OR (
Posts.CreateAt > @data_retention_channel2_timestamp
AND ChannelId = @data_retion_channel2_channel_id
)
OR (
Posts.CreateAt > @data_retention_team1_timestamp
AND Teams.Id = @data_retion_team1_team_id
AND ChannelId NOT IN (@data_retention_channels_channel_ids)
)
OR (
Posts.CreateAt > @data_retention_team2_timestamp
AND Teams.Id = @data_retion_team2_team_id
AND ChannelId NOT IN (@data_retention_channels_channel_ids)
)
OR (
Posts.CreateAt > @global_retention_timestamp
AND ChannelId NOT IN (@data_retention_channels_channel_ids)
AND Teams.Id NOT IN (@data_retention_teams_team_ids)
); |
The post ids returned from that query can be used to delete, the output of which can be a list of post ids to be used to delete Posts
records and the following:
Reactions
Preferences
(ofCategory
‘flagged_post’)Threads
ThreadMemberships
LinkMetadata
TBD: these aren’t currently purged via data retention, but they probably should be.
FileInfo
(and their associated files on disk) and ChannelMemberHistory
continue to be deleted system-wide with no new granularity.
TBD: Why is ChannelMemberHistory
currently deleted as part of message retention days settings?
Mobile
No changes. Existing file-deleted and post-deleted UX covers all.