Merge pull request #1706 from nextcloud/verify-existance-of-room-capabilities

Verify existance of room capabilities
This commit is contained in:
Ivan Sein 2024-07-18 20:41:58 +02:00 коммит произвёл GitHub
Родитель 9ce7b37690 8207864bfb
Коммит 75252344dd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 14 добавлений и 4 удалений

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

@ -188,12 +188,14 @@ class BaseChatTableViewCell: UITableViewCell, ReactionsViewDelegate {
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
guard let room = NCDatabaseManager.sharedInstance().room(withToken: message.token, forAccountId: activeAccount.accountId),
let roomCapabilities = NCDatabaseManager.sharedInstance().roomTalkCapabilities(for: room)
guard let room = NCDatabaseManager.sharedInstance().room(withToken: message.token, forAccountId: activeAccount.accountId)
else { return }
let shouldShowDeliveryStatus = NCDatabaseManager.sharedInstance().roomHasTalkCapability(kCapabilityChatReadStatus, for: room)
let shouldShowReadStatus = !roomCapabilities.readStatusPrivacy
// In case we are not able to retrieve the capabilities of the room, we fall back to readPrivacy = true -> hiding the read status
let roomCapabilities = NCDatabaseManager.sharedInstance().roomTalkCapabilities(for: room)
let shouldShowReadStatus = !(roomCapabilities?.readStatusPrivacy ?? true)
// This check is just a workaround to fix the issue with the deleted parents returned by the API.
if let parent = message.parent {

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

@ -3297,7 +3297,15 @@ NSInteger const kReceivedChatMessagesLimit = 100;
NSPredicate *query = [NSPredicate predicateWithFormat:@"token = %@ AND accountId = %@", token, account.accountId];
NCRoom *managedRoom = [NCRoom objectsWithPredicate:query].firstObject;
if (!managedRoom || [proxyHash isEqualToString:managedRoom.lastReceivedProxyHash]) {
if (!managedRoom) {
// The room is not known to us locally, don't try to fetch room capabilities
return;
}
FederatedCapabilities *federatedCapabilities = [[NCDatabaseManager sharedInstance] federatedCapabilitiesForAccountId:managedRoom.accountId remoteServer:managedRoom.remoteServer roomToken:managedRoom.token];
if ([proxyHash isEqualToString:managedRoom.lastReceivedProxyHash] && federatedCapabilities != nil) {
// The proxy hash is equal to our last known proxy hash and we are also able to retrieve capabilities locally -> skip fetching capabilities
return;
}