Allow to request assistance in breakout rooms.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2023-02-24 09:56:15 +01:00
Родитель df93fae4fb
Коммит 5cc5a5d013
5 изменённых файлов: 87 добавлений и 0 удалений

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

@ -51,6 +51,8 @@ typedef void (^SetSIPStateCompletionBlock)(NSError *error);
typedef void (^ListableCompletionBlock)(NSError *error);
typedef void (^MessageExpirationCompletionBlock)(NSError *error);
typedef void (^RequestAssistanceCompletionBlock)(NSError *error);
typedef void (^GetParticipantsFromRoomCompletionBlock)(NSMutableArray *participants, NSError *error);
typedef void (^LeaveRoomCompletionBlock)(NSInteger errorCode, NSError *error);
typedef void (^ParticipantModificationCompletionBlock)(NSError *error);
@ -132,6 +134,7 @@ extern NSInteger const kReceivedChatMessagesLimit;
- (NSInteger)chatAPIVersionForAccount:(TalkAccount *)accounts;
- (NSInteger)reactionsAPIVersionForAccount:(TalkAccount *)account;
- (NSInteger)pollsAPIVersionForAccount:(TalkAccount *)account;
- (NSInteger)breakoutRoomsAPIVersionForAccount:(TalkAccount *)account;
- (NSInteger)signalingAPIVersionForAccount:(TalkAccount *)account;
- (NSString *)filesPathForAccount:(TalkAccount *)account;
@ -161,6 +164,10 @@ extern NSInteger const kReceivedChatMessagesLimit;
- (NSURLSessionDataTask *)setListableScope:(NCRoomListableScope)scope forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(ListableCompletionBlock)block;
- (NSURLSessionDataTask *)setMessageExpiration:(NCMessageExpiration)messageExpiration forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(MessageExpirationCompletionBlock)block;
// Breakout Rooms Controller
- (NSURLSessionDataTask *)requestAssistanceInRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(RequestAssistanceCompletionBlock)block;
- (NSURLSessionDataTask *)stopRequestingAssistanceInRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(RequestAssistanceCompletionBlock)block;
// Participants Controller
- (NSURLSessionDataTask *)getParticipantsFromRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(GetParticipantsFromRoomCompletionBlock)block;
- (NSURLSessionDataTask *)addParticipant:(NSString *)participant ofType:(NSString *)type toRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(ParticipantModificationCompletionBlock)block;

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

@ -168,6 +168,11 @@ NSInteger const kReceivedChatMessagesLimit = 100;
return APIv1;
}
- (NSInteger)breakoutRoomsAPIVersionForAccount:(TalkAccount *)account
{
return APIv1;
}
- (NSInteger)signalingAPIVersionForAccount:(TalkAccount *)account
{
NSInteger signalingAPIVersion = APIv1;
@ -790,6 +795,54 @@ NSInteger const kReceivedChatMessagesLimit = 100;
return task;
}
#pragma mark - Breakout Rooms Controller
- (NSURLSessionDataTask *)requestAssistanceInRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(RequestAssistanceCompletionBlock)block
{
NSString *encodedToken = [token stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *endpoint = [NSString stringWithFormat:@"breakout-rooms/%@/request-assistance", encodedToken];
NSInteger breakoutRoomsAPIVersion = [self breakoutRoomsAPIVersionForAccount:account];
NSString *URLString = [self getRequestURLForEndpoint:endpoint withAPIVersion:breakoutRoomsAPIVersion forAccount:account];
NCAPISessionManager *apiSessionManager = [_apiSessionManagers objectForKey:account.accountId];
NSURLSessionDataTask *task = [apiSessionManager POST:URLString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (block) {
block(nil);
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSInteger statusCode = [self getResponseStatusCode:task.response];
[self checkResponseStatusCode:statusCode forAccount:account];
if (block) {
block(error);
}
}];
return task;
}
- (NSURLSessionDataTask *)stopRequestingAssistanceInRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(RequestAssistanceCompletionBlock)block
{
NSString *encodedToken = [token stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *endpoint = [NSString stringWithFormat:@"breakout-rooms/%@/request-assistance", encodedToken];
NSInteger breakoutRoomsAPIVersion = [self breakoutRoomsAPIVersionForAccount:account];
NSString *URLString = [self getRequestURLForEndpoint:endpoint withAPIVersion:breakoutRoomsAPIVersion forAccount:account];
NCAPISessionManager *apiSessionManager = [_apiSessionManagers objectForKey:account.accountId];
NSURLSessionDataTask *task = [apiSessionManager DELETE:URLString parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (block) {
block(nil);
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSInteger statusCode = [self getResponseStatusCode:task.response];
[self checkResponseStatusCode:statusCode forAccount:account];
if (block) {
block(error);
}
}];
return task;
}
#pragma mark - Participants Controller
- (NSURLSessionDataTask *)getParticipantsFromRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(GetParticipantsFromRoomCompletionBlock)block

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

@ -459,6 +459,25 @@ static NSString * const kNCVideoTrackKind = @"video";
}
}
}];
// Request or stop requesting assistance if we are in a breakout room
if (![_room isBreakoutRoom]) {
return;
}
if (raised) {
[[NCAPIController sharedInstance] requestAssistanceInRoom:_room.token forAccount:_account withCompletionBlock:^(NSError *error) {
if (error) {
NSLog(@"Error requesting assistance");
}
}];
} else {
[[NCAPIController sharedInstance] stopRequestingAssistanceInRoom:_room.token forAccount:_account withCompletionBlock:^(NSError *error) {
if (error) {
NSLog(@"Error on stop requesting assisntance");
}
}];
}
}
- (void)startRecording

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

@ -94,6 +94,7 @@ typedef enum NCCallRecordingState {
extern NSString * const NCRoomObjectTypeFile;
extern NSString * const NCRoomObjectTypeSharePassword;
extern NSString * const NCRoomObjectTypeRoom;
@interface NCRoom : RLMObject
@ -155,6 +156,7 @@ extern NSString * const NCRoomObjectTypeSharePassword;
+ (void)updateRoom:(NCRoom *)managedRoom withRoom:(NCRoom *)room;
- (BOOL)isPublic;
- (BOOL)isBreakoutRoom;
- (BOOL)isUserOwnerOrModerator;
- (BOOL)canModerate;
- (BOOL)isNameEditable;

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

@ -26,6 +26,7 @@
NSString * const NCRoomObjectTypeFile = @"file";
NSString * const NCRoomObjectTypeSharePassword = @"share:password";
NSString * const NCRoomObjectTypeRoom = @"room";
@implementation NCRoom
@ -194,6 +195,11 @@ NSString * const NCRoomObjectTypeSharePassword = @"share:password";
return self.type == kNCRoomTypePublic;
}
- (BOOL)isBreakoutRoom
{
return self.objectType == NCRoomObjectTypeRoom;
}
- (BOOL)isUserOwnerOrModerator
{
return self.participantType == kNCParticipantTypeOwner || self.participantType == kNCParticipantTypeModerator;