Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Summary

Adds the ability to configure custom (granular) deletion policies for posts and/or files for specific teams and/or channels so that when . When the daily retention job runs it can selectively delete those resources selectively deletes posts by age based on their configurationthe configuration.

The granular policies completely override the global setting.

The feature requires some new APIs, some new tables, and an edit to the existing data retention job logic.

API

...

Global Policy (existing API)

GET /api/v4/data_retention/policy (existing). Retrieves retrieves the global retention settings:.

Code Block
{
    "message_deletion_enabled": false,
    "file_deletion_enabled": false,
    "message_retention_cutoff": 0,
    "file_retention_cutoff": 0
}

...

The JSON object reflects the fields in the DataRetentionSettings config object for:

  • EnableMessageDeletion

  • EnableFileDeletion

  • MessageRetentionDays

  • FileRetentionDays

Updates to the global retention policy continues to be managed via the config APIs.

...

Retention Policies

POST /api/v4/retention_policies to create a new retention policy with the following payload.

Request:

Code Block
languagejson
{
    "filedisplay_retention_durationname": 2"foo",
    "message_retentionpost_duration": 4
}

201 response:

Code Block
{
    "id": "m8zoumpj9pn9zexospoxi5dzoc",
    "display_name": "foo",
    "post_duration": 4
}

...

PUT /api/v4/retention_policies/:policy_id/patch to patch patches a retention policy.

Request:

Code Block
{
    "display_name": "foo2",
    "file_retention_durationpost_duration": 365
}

200 Response:

Code Block
{
    "id": 90"m8zoumpj9pn9zexospoxi5dzoc",
    "message_retentiondisplay_name": "foo2",
    "post_duration": 365
}

...

GET /api/v4/retention_policies/:policy_id to get gets a retention policy by id

DELETE /api/v4/retention_policies/:policy_id to delete a retention policy

GET /api/v4/retention_policies?page=0&per_page=100 to list retention policies

...

.

Code Block
{
    "id": "m8zoumpj9pn9zexospoxi5dzoc",
    "display_name": "foo2",
    "post_duration": 365,
    "policiesteams": [
        {
            "file_retention_durationid": 2"z7rxbxbfb7yxdydxzi8pestath",
            "messagedisplay_retention_durationname": 2,
 "My Team 1"
        }
    ],
    "channels": [
        {
  "display_name          "id": "fooz7rxbxbfb7yxdydxzi8pestath",
        }     ],"display_name": "Off Topic",
            "totalteam_display_countname": "My Team 1"
        }
    ]
}

...

...

DELETE /api/v4/retention_policies/:policy_id deletes a retention policy.

Deleting a RetentionPolicies record also deletes all of the associated RetentionPoliciesChannels and RetentionPoliciesTeams records.

...

GET /api/v4/retention_policies_teamspolicies lists all retention policies, including associated teams and channels.

Code Block
languagejson
{
    "policies": [
        {
            "policydisplay_idname": "m8zoumpj9pn9zexospoxi5dzocfoo",
            "teampost_idduration": 2,
            "z7rxbxbfb7yxdydxzi8pestathteams": [
        }        {
        ],     "total_count": 1 }

POST /api/v4/retention_policies_teams

Code Block
{     "policy_id": "m8zoumpj9pn9zexospoxi5dzocz7rxbxbfb7yxdydxzi8pestath",
                    "teamdisplay_idname": "z7rxbxbfb7yxdydxzi8pestath"
}

DELETE /api/v4/retention_policies_teams/team_id

Retention Policies Channels

GET /api/v4/retention_policies_channels

Code Block
{My Team 1"
                }
            ],
            "policieschannels": [
                {
            "policy_id        "id": "z7rxbxbfb7yxdydxzi8pestath",
                    "display_name": "m8zoumpj9pn9zexospoxi5dzocOff Topic",
                    "channelteam_display_idname": "z7rxbxbfb7yxdydxzi8pestath"My Team 1"
                }
            ]
        }
    ],
    "total_count": 1
}

...

Retention Policies Teams

POST /api/v4/retention_policies_channels/:policy_id/teams associates a team to a retention policy.

Request:

Code Block
{
    "team_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.

...

Retention Policies Channels

POST /api/v4/retention_policies/:policy_id/channels associates a channel to a retention policy.

Request:

Code Block
{
    "channel_ids": ["m8zoumpj9pn9zexospoxi5dzoc",z7rxbxbfb7yxdydxzi8pestath"]
}

Response:

Code Block
{
    "channelsuccess_idids": ["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.

...

Database

RetentionPolicies table

Column name

Description

Id

varchar, primary key

DisplayName

varchar

PostDuration

int, the duration in days to keep posts

FileDuration

int, the duration in days to keep files

RetentionPoliciesChannelsRetentionPoliciesChannels table

Column name

Description

PolicyId

varchar, the RetentionPolicies.Id foreign key

ChannelId

varchar, the Channels.Id foreign key

TBD: Does ChannelId need to be indexed?

RetentionPoliciesTeams table

Column name

Description

PolicyId

varchar, the RetentionPolicies.Id foreign key

TeamId

varchar, the Teams.Id foreign key

TBD: Does TeamId need to be indexed?

Model

  • Rename DataRetentionPolicy to GlobalDataRetentionPolicy

  • Add RetentionPolicy representing a record in the RetentionPolicies table.

  • Add RetentionPolicyChannel representing a record in the RetentionPoliciesChannels table.

  • Add RetentionPolicyTeam representing a record in the RetentionPoliciesTeams table.

Enterprise

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, the output of which can be a list of post ids to be used to delete Posts records and the following:

  • Reactions

  • Preferences (of Category ‘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.