// // YMRoomTopicPresenter.m // YUMI // // Created by YUMI on 2022/3/14. // #import "XPRoomTopicPresenter.h" #import #import "YUMIConstant.h" #import "DESEncrypt.h" #import "AccountInfoStorage.h" #import "Api+RoomSetting.h" #import "XPRoomTopicProtocol.h" #import "RoomInfoModel.h" #import "NSMutableDictionary+Saft.h" @implementation XPRoomTopicPresenter ///更新房间信息 - (void)roomTopicUpdate:(NSString *)roomDesc introduction:(NSString *)introduction roomInfo:(RoomInfoModel *)roomInfo { NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; NSMutableDictionary * params = [NSMutableDictionary dictionary]; [params safeSetObject:ticket forKey:@"ticket"]; [params safeSetObject:uid forKey:@"uid"]; [params safeSetObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; if (roomInfo.title.length > 0) { [params safeSetObject:roomInfo.title forKey:@"title"]; } if (roomInfo.roomPwd.length > 0) { [params safeSetObject:roomInfo.roomPwd forKey:@"roomPwd"]; } if (roomInfo.tagId > 0) { [params safeSetObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; } [params safeSetObject:roomDesc forKey:@"roomDesc"]; if (introduction.length > 0) { [params safeSetObject:introduction forKey:@"introduction"]; } [params safeSetObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; ///获取房间角色 NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; request.userIds = @[uid]; [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { if (error == nil) { NIMChatroomMember * member = members.firstObject; if (member.type == NIMTeamMemberTypeOwner) { [Api ownerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { [[self getView] updateRoomTopicSuccess]; } showLoading:YES] params:params]; } else if(member.type == NIMTeamMemberTypeManager) { [Api managerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { [[self getView] updateRoomTopicSuccess]; } showLoading:YES] params:params]; } } else { [[self getView] updateRoomTopicFail:YMLocalizedString(@"XPRoomTopicPresenter0")]; } }]; } @end