From cffe80b442bb1d3c77bca818eed48675ea36222d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Tue, 20 Jun 2023 19:52:05 +0200 Subject: [PATCH] Fix fetching unreads from archived channels, fetching groups on unlicensed servers and logs (#7406) --- app/actions/remote/groups.ts | 10 +++++----- app/actions/remote/post.ts | 2 +- app/utils/errors.ts | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/actions/remote/groups.ts b/app/actions/remote/groups.ts index e402226b3c..50d6a5fca4 100644 --- a/app/actions/remote/groups.ts +++ b/app/actions/remote/groups.ts @@ -17,7 +17,7 @@ export const fetchGroupsForAutocomplete = async (serverUrl: string, query: strin try { const {operator, database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const license = await getLicense(database); - if (!license || !license.IsLicensed) { + if (!license || license.IsLicensed !== 'true') { return []; } @@ -40,7 +40,7 @@ export const fetchGroupsByNames = async (serverUrl: string, names: string[], fet try { const {operator, database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const license = await getLicense(database); - if (!license || !license.IsLicensed) { + if (!license || license.IsLicensed !== 'true') { return []; } @@ -70,7 +70,7 @@ export const fetchGroupsForChannel = async (serverUrl: string, channelId: string try { const {operator, database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const license = await getLicense(database); - if (!license || !license.IsLicensed) { + if (!license || license.IsLicensed !== 'true') { return {groups: [], groupChannels: []}; } @@ -102,7 +102,7 @@ export const fetchGroupsForTeam = async (serverUrl: string, teamId: string, fetc try { const {operator, database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const license = await getLicense(database); - if (!license || !license.IsLicensed) { + if (!license || license.IsLicensed !== 'true') { return {groups: [], groupTeams: []}; } @@ -133,7 +133,7 @@ export const fetchGroupsForMember = async (serverUrl: string, userId: string, fe try { const {operator, database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const license = await getLicense(database); - if (!license || !license.IsLicensed) { + if (!license || license.IsLicensed !== 'true') { return {groups: [], groupMemberships: []}; } diff --git a/app/actions/remote/post.ts b/app/actions/remote/post.ts index 7a5add8e6b..3c26ff0acc 100644 --- a/app/actions/remote/post.ts +++ b/app/actions/remote/post.ts @@ -339,7 +339,7 @@ export const fetchPostsForUnreadChannels = async (serverUrl: string, channels: C const promises = []; for (const member of memberships) { const channel = channels.find((c) => c.id === member.channel_id); - if (channel && (channel.total_msg_count - member.msg_count) > 0 && channel.id !== excludeChannelId) { + if (channel && !channel.delete_at && (channel.total_msg_count - member.msg_count) > 0 && channel.id !== excludeChannelId) { promises.push(fetchPostsForChannel(serverUrl, channel.id)); } } diff --git a/app/utils/errors.ts b/app/utils/errors.ts index f0451c0487..f0f013541e 100644 --- a/app/utils/errors.ts +++ b/app/utils/errors.ts @@ -28,7 +28,8 @@ export function isErrorWithDetails(obj: unknown): obj is {details: Error} { return ( typeof obj === 'object' && obj !== null && - 'details' in obj + 'details' in obj && + typeof obj.details !== 'undefined' ); }