forked from Ivasoft/mattermost-mobile
[MM-47548 Gekidou] Data Retention Implementation (#6732)
* Fetch & Save granular data retention policies through REST * Init Data cleanup * Run the clean up * Deleting posts in patches and running across other servers * fetch on graphql & refactor * Feedback changes * Added try catch for deletePosts function * Feedback changes * Changed to 'for of' loop * Misc * app/actions * Date cutoff fox * Prevent showing loading bar when request fails Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
committed by
GitHub
parent
24ec88096c
commit
eb46a6aeff
@@ -158,6 +158,50 @@ export const getConfigValue = async (database: Database, key: keyof ClientConfig
|
||||
return list.length ? list[0].value : undefined;
|
||||
};
|
||||
|
||||
export const getLastGlobalDataRetentionRun = async (database: Database) => {
|
||||
try {
|
||||
const data = await database.get<SystemModel>(SYSTEM).find(SYSTEM_IDENTIFIERS.LAST_DATA_RETENTION_RUN);
|
||||
return data?.value || 0;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const getGlobalDataRetentionPolicy = async (database: Database) => {
|
||||
try {
|
||||
const data = await database.get<SystemModel>(SYSTEM).find(SYSTEM_IDENTIFIERS.DATA_RETENTION_POLICIES);
|
||||
return (data?.value || {}) as GlobalDataRetentionPolicy;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const getGranularDataRetentionPolicies = async (database: Database) => {
|
||||
try {
|
||||
const data = await database.get<SystemModel>(SYSTEM).find(SYSTEM_IDENTIFIERS.GRANULAR_DATA_RETENTION_POLICIES);
|
||||
return (data?.value || {
|
||||
team: [],
|
||||
channel: [],
|
||||
}) as {
|
||||
team: TeamDataRetentionPolicy[];
|
||||
channel: ChannelDataRetentionPolicy[];
|
||||
};
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const getIsDataRetentionEnabled = async (database: Database) => {
|
||||
const license = await getLicense(database);
|
||||
if (!license || !Object.keys(license)?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const dataRetentionEnableMessageDeletion = await getConfigValue(database, 'DataRetentionEnableMessageDeletion');
|
||||
|
||||
return dataRetentionEnableMessageDeletion === 'true' && license?.IsLicensed === 'true' && license?.DataRetention === 'true';
|
||||
};
|
||||
|
||||
export const observeConfig = (database: Database): Observable<ClientConfig | undefined> => {
|
||||
return database.get<ConfigModel>(CONFIG).query().observeWithColumns(['value']).pipe(
|
||||
switchMap((result) => of$(fromModelToClientConfig(result))),
|
||||
|
||||
Reference in New Issue
Block a user