702 lines
27 KiB
Objective-C
702 lines
27 KiB
Objective-C
//
|
||
// YMUserCardPresenter.m
|
||
// YUMI
|
||
//
|
||
// Created by YUMI on 2021/11/24.
|
||
//
|
||
|
||
#import "XPUserCardPresenter.h"
|
||
///Third
|
||
#import <NIMSDK/NIMSDK.h>
|
||
#import <ReactiveObjC/ReactiveObjC.h>
|
||
///Tool
|
||
#import "Api+UserCard.h"
|
||
#import "AccountInfoStorage.h"
|
||
///Model
|
||
#import "UserInfoModel.h"
|
||
#import "XPUserCardItemModel.h"
|
||
#import "XPUserCardInfoModel.h"
|
||
#import "XPUserCardMicroItemModel.h"
|
||
#import "XPKickUserModel.h"
|
||
#import "AttachmentModel.h"
|
||
///P
|
||
#import "XPUserCardProtocol.h"
|
||
|
||
@interface XPUserCardPresenter ()
|
||
///礼物的
|
||
@property (nonatomic,strong) XPUserCardItemModel *giftItem;
|
||
///私聊
|
||
@property (nonatomic,strong) XPUserCardItemModel *chatItem;
|
||
///关注
|
||
@property (nonatomic,strong) XPUserCardItemModel *attentionItem;
|
||
///设置管理员
|
||
@property (nonatomic,strong) XPUserCardItemModel *managerItem;
|
||
///踢出房间
|
||
@property (nonatomic,strong) XPUserCardItemModel *kikoutItem;
|
||
///加入黑名单
|
||
@property (nonatomic,strong) XPUserCardItemModel *blackItem;
|
||
///@TA
|
||
@property (nonatomic, strong) XPUserCardItemModel *atItem;
|
||
///操作的数组
|
||
@property (nonatomic,strong) NSMutableArray * functionArray;
|
||
@end
|
||
|
||
@implementation XPUserCardPresenter
|
||
|
||
/// 获取用户信息
|
||
/// @param uid 查询的用户的uid
|
||
- (void)getUserInfo:(NSString *)uid {
|
||
if (uid == nil) {
|
||
return;
|
||
}
|
||
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
||
[[self getView] onGetUserInfoSuccess:infoModel];
|
||
}] uid:uid];
|
||
}
|
||
|
||
|
||
/// 两个人的关注状态
|
||
/// @param uid 自己的uid
|
||
/// @param targetUid 对方的uid
|
||
- (void)userAttentionStatus:(NSString *)uid targetUid:(NSString *)targetUid {
|
||
[Api attentionStatusCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
BOOL isLike = ((NSNumber *)data.data).boolValue;
|
||
self.attentionItem.isSelect = isLike;
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}] uid:uid isLikeUid:targetUid];
|
||
}
|
||
|
||
|
||
/// 获取用户卡片中中间操作按钮的数据源
|
||
/// @param userInfo 目标用户
|
||
- (void)getFunctionItemsByUserInfo:(XPUserCardInfoModel *)userInfo{
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NSString * targetUid = userInfo.uid;
|
||
NSString * roomId = [NSString stringWithFormat:@"%ld", userInfo.roomInfo.roomId];
|
||
if ([uid isEqualToString:targetUid]) { ///查看自己的话 没有中间的数据
|
||
return;
|
||
} else {
|
||
[self.functionArray removeAllObjects];
|
||
if (!userInfo.hideSendGiftItem) {
|
||
[self.functionArray addObject:self.giftItem];
|
||
}
|
||
[self.functionArray addObject:self.chatItem];
|
||
[self.functionArray addObject:self.atItem];
|
||
[self.functionArray addObject:self.attentionItem];
|
||
///获取一下关注的状态
|
||
[self userAttentionStatus:uid targetUid:targetUid];
|
||
///自己是公会超管
|
||
BOOL meIsSuperAdmin = NO;
|
||
///用户卡片的那个人事公会超管
|
||
BOOL heIsSuperAdmin = NO;
|
||
for (GuildSuperAdminInfoModel *managerInfo in userInfo.superMangerList) {
|
||
if ([managerInfo.uid isEqualToString:userInfo.uid]) {
|
||
heIsSuperAdmin = YES;
|
||
}
|
||
if ([managerInfo.uid isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||
meIsSuperAdmin = YES;
|
||
}
|
||
}
|
||
@weakify(self);
|
||
if (meIsSuperAdmin) {
|
||
if (heIsSuperAdmin) {
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
} else {
|
||
///查看 目标用户是否是管理员
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
NIMChatroomMember * targetMember = x;
|
||
if (targetMember == nil) {return;}
|
||
if (targetMember.type == NIMChatroomMemberTypeCreator) { ///目标是房主的话
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
} else {
|
||
if (targetMember && targetMember.type == NIMChatroomMemberTypeManager) {
|
||
self.managerItem.isSelect = YES;
|
||
}
|
||
[self.functionArray addObject:self.managerItem];
|
||
[self.functionArray addObject:self.kikoutItem];
|
||
[self.functionArray addObject:self.blackItem];
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}
|
||
}];
|
||
}
|
||
} else {
|
||
[[self rac_queryChatRoomMember:uid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
@strongify(self);
|
||
NIMChatroomMember * member = x;
|
||
if (member == nil) {return;}
|
||
if (member.type == NIMChatroomMemberTypeCreator) {///房主 踢出房间 设置管理员 拉黑
|
||
if (heIsSuperAdmin) {
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
} else {
|
||
[self.functionArray addObject:self.kikoutItem];
|
||
[self.functionArray addObject:self.managerItem];
|
||
[self.functionArray addObject:self.blackItem];
|
||
///查看 目标用户是否是管理员
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
NIMChatroomMember * targetMember = x;
|
||
if (targetMember && targetMember.type == NIMChatroomMemberTypeManager) {
|
||
self.managerItem.isSelect = YES;
|
||
}
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}];
|
||
}
|
||
} else if(member.type == NIMChatroomMemberTypeManager) {///操作者是 管理员 踢出房间 拉黑
|
||
///查看 目标用户是否是管理员
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
NIMChatroomMember * targetMember = x;
|
||
if (targetMember == nil) {return;}
|
||
if (targetMember.type == NIMChatroomMemberTypeManager || targetMember.type == NIMChatroomMemberTypeCreator || heIsSuperAdmin) { ///目标是管理员
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
} else {
|
||
[self.functionArray addObject:self.kikoutItem];
|
||
[self.functionArray addObject:self.blackItem];
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}
|
||
}];
|
||
} else {
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}
|
||
}];
|
||
}
|
||
}
|
||
}
|
||
|
||
///抱她上麦的 数据
|
||
/// @param micCount 当前麦序的个数
|
||
- (void)getRoomMicroItems:(int)micCount cardInfo:(XPUserCardInfoModel *)cardInfo {
|
||
[self.functionArray removeAllObjects];
|
||
RoomInfoModel * roomInfo = cardInfo.roomInfo;
|
||
NSMutableDictionary * micQueue = cardInfo.micQueue;
|
||
for (int i = 0; i < micCount; i++) {
|
||
XPUserCardItemModel * item = [[XPUserCardItemModel alloc] init];
|
||
item.type = UserCardItemType_Invite_Micro;
|
||
if (i == 0) {
|
||
item.title = roomInfo.roomModeType == RoomModeType_Open_Blind ?YMLocalizedString(@"XPUserCardPresenter21") : YMLocalizedString(@"XPUserCardPresenter1");
|
||
item.imageName = roomInfo.leaveMode ? @"usercard_invite_micro_owner_disable" : @"usercard_invite_micro_owner";
|
||
if (roomInfo.leaveMode) {
|
||
item.isEnable = NO;
|
||
}
|
||
} else {
|
||
if (roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||
if (i == 1 || i == 2 || i == 5 || i == 6) {
|
||
item.title = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardPresenter2"), i];
|
||
} else{
|
||
item.title = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardPresenter3"), i];
|
||
}
|
||
} else {
|
||
item.title = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardPresenter4"), i];
|
||
}
|
||
|
||
}
|
||
MicroQueueModel * micModel = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i -1]];
|
||
if (micModel && micModel.userInfo && micModel.userInfo.uid > 0) {
|
||
item.isEnable = NO;
|
||
item.imageName = @"usercard_invite_micro_disable";
|
||
} else {
|
||
item.isEnable = YES;
|
||
item.imageName = @"usercard_invite_micro_normal";
|
||
}
|
||
item.position = [NSString stringWithFormat:@"%d", (i - 1)];
|
||
[self.functionArray addObject:item];
|
||
}
|
||
[[self getView] onGetFunctionArraySccess:self.functionArray];
|
||
}
|
||
|
||
/// 用户卡片底部的操作按钮
|
||
/// @param userInfo 目标用户的信息
|
||
- (void)getMicroFunctionItemsByUserInfo:(XPUserCardInfoModel *)userInfo {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NSString * targetUid = userInfo.uid;
|
||
RoomInfoModel * roomInfo = userInfo.roomInfo;
|
||
NSString * roomId = [NSString stringWithFormat:@"%ld", userInfo.roomInfo.roomId];
|
||
MicroQueueModel * micQueue = [userInfo.micQueue objectForKey:userInfo.position];
|
||
NSMutableArray * array = [NSMutableArray array];
|
||
XPUserCardMicroItemModel * muteItem = [[XPUserCardMicroItemModel alloc] init];
|
||
muteItem.title = userInfo.micState == MicroMicStateType_Open ? YMLocalizedString(@"StageView25") : YMLocalizedString(@"XPUserCardPresenter6");
|
||
muteItem.status = userInfo.micState == MicroMicStateType_Open;
|
||
muteItem.type = UserCardMicroType_Mute;
|
||
|
||
XPUserCardMicroItemModel * upDownItem = [[XPUserCardMicroItemModel alloc] init];
|
||
upDownItem.title = userInfo.position.length <= 0 ? YMLocalizedString(@"StageView18") : [uid isEqualToString:targetUid] ? YMLocalizedString(@"StageView28") : YMLocalizedString(@"XPUserCardPresenter9");
|
||
upDownItem.status = userInfo.position.length > 0 ? YES : NO;
|
||
upDownItem.type = UserCardMicroType_UpDown;
|
||
|
||
XPUserCardMicroItemModel * lockItem = [[XPUserCardMicroItemModel alloc] init];
|
||
lockItem.title = userInfo.posState == MicroPosStateType_Free ? YMLocalizedString(@"StageView23") : YMLocalizedString(@"XPUserCardPresenter11");
|
||
lockItem.status = userInfo.posState == MicroPosStateType_Free;
|
||
lockItem.type = UserCardMicroType_Lock;
|
||
|
||
XPUserCardMicroItemModel * giftValueItem = [[XPUserCardMicroItemModel alloc] init];
|
||
giftValueItem.title = YMLocalizedString(@"XPUserCardPresenter12");
|
||
giftValueItem.type = UserCardMicroType_Clean_Gift_Value;
|
||
///自己是公会超管
|
||
BOOL meIsSuperAdmin = NO;
|
||
///用户卡片的那个人事公会超管
|
||
BOOL heIsSuperAdmin = NO;
|
||
for (GuildSuperAdminInfoModel *managerInfo in userInfo.superMangerList) {
|
||
if ([managerInfo.uid isEqualToString:userInfo.uid]) {
|
||
heIsSuperAdmin = YES;
|
||
}
|
||
if ([managerInfo.uid isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||
meIsSuperAdmin = YES;
|
||
}
|
||
}
|
||
if ([targetUid isEqualToString:uid]) {///自己看自己
|
||
@weakify(self);
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
@strongify(self);
|
||
NIMChatroomMember * member = x;
|
||
if (member == nil) {return;}
|
||
if (userInfo.roomInfo.type == RoomType_Anchor) {///个播房点击自己
|
||
if (member.type == NIMChatroomMemberTypeCreator) {
|
||
[array addObject:muteItem];
|
||
[array addObject:lockItem];
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else if(member.type == NIMTeamMemberTypeManager || meIsSuperAdmin) {
|
||
[array addObject:muteItem];
|
||
if (userInfo.position.length > 0) {
|
||
[array addObject:upDownItem];
|
||
}
|
||
[array addObject:lockItem];
|
||
if (userInfo.roomInfo.type == RoomType_Anchor && userInfo.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {//个播PK中不显示上麦
|
||
[array removeAllObjects];
|
||
}
|
||
} else {
|
||
if (userInfo.position.length > 0) {
|
||
[array addObject:upDownItem];
|
||
}
|
||
if (userInfo.roomInfo.type == RoomType_Anchor && userInfo.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {//个播PK中不显示上麦
|
||
[array removeAllObjects];
|
||
}
|
||
}
|
||
} else {
|
||
if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager || meIsSuperAdmin) {
|
||
if (userInfo.roomInfo.leaveMode && userInfo.uid.integerValue == userInfo.roomInfo.uid && [userInfo.position isEqualToString:@"-1"]) {
|
||
[array addObject:muteItem];
|
||
[array addObject:upDownItem];
|
||
[array addObject:lockItem];
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else {
|
||
if (userInfo.position.length > 0) {
|
||
[array addObject:muteItem];
|
||
[array addObject:upDownItem];
|
||
if (![userInfo.position isEqualToString:@"999"]) {
|
||
[array addObject:lockItem];
|
||
}
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else {
|
||
[array addObject:upDownItem];
|
||
}
|
||
}
|
||
} else {
|
||
if (userInfo.position.length > 0) {
|
||
[array addObject:upDownItem];
|
||
}
|
||
}
|
||
}
|
||
[[self getView] onGetMicroFunctionArraySuccess:array];
|
||
}];
|
||
} else {///不是自己看自己
|
||
@weakify(self);
|
||
[[self rac_queryChatRoomMember:uid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
@strongify(self);
|
||
NIMChatroomMember * member = x;
|
||
if (member == nil) {return;}
|
||
if (member.type == NIMChatroomMemberTypeCreator) {
|
||
if (userInfo.position.length > 0) {
|
||
if (micQueue.userInfo.vipMic) {
|
||
[array addObject:muteItem];
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else {
|
||
[array addObject:muteItem];
|
||
[array addObject:upDownItem];
|
||
[array addObject:lockItem];
|
||
if (userInfo.roomInfo.type != RoomType_Anchor) {//非个播房显示清除礼物值
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
[array addObject:upDownItem];
|
||
}
|
||
if (userInfo.roomInfo.type == RoomType_Anchor && userInfo.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {
|
||
[array removeAllObjects];
|
||
}
|
||
[[self getView] onGetMicroFunctionArraySuccess:array];
|
||
} else if(member.type == NIMChatroomMemberTypeManager || meIsSuperAdmin) {/// 管理员
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
NIMChatroomMember * targetMember = x;
|
||
if (targetMember == nil) {return;}
|
||
if (userInfo.roomInfo.type == RoomType_Anchor) {//个播模式
|
||
if (userInfo.position.length > 0) {
|
||
if (targetMember.type != NIMChatroomMemberTypeManager && targetMember.type != NIMChatroomMemberTypeCreator) {
|
||
[array addObject:muteItem];
|
||
}
|
||
if (targetMember.type != NIMChatroomMemberTypeCreator) {
|
||
[array addObject:upDownItem];
|
||
}
|
||
[array addObject:lockItem];
|
||
}
|
||
|
||
if (userInfo.uid.integerValue == userInfo.roomInfo.uid && [userInfo.position isEqualToString:@"-1"]) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
|
||
} else {
|
||
if (targetMember.type == NIMChatroomMemberTypeCreator) {
|
||
if (userInfo.position.length > 0) {
|
||
if (!micQueue.userInfo.vipMic) {
|
||
[array addObject:lockItem];
|
||
}
|
||
} else {
|
||
[array addObject:upDownItem];
|
||
}
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else {///目标者是普通用户
|
||
if (userInfo.position.length > 0) {
|
||
if (targetMember.type != NIMChatroomMemberTypeManager) {
|
||
[array addObject:muteItem];
|
||
}
|
||
if (!micQueue.userInfo.vipMic) {
|
||
[array addObject:upDownItem];
|
||
[array addObject:lockItem];
|
||
}
|
||
if (roomInfo.showGiftValue) {
|
||
[array addObject:giftValueItem];
|
||
}
|
||
} else {
|
||
[array addObject:upDownItem];
|
||
}
|
||
}
|
||
}
|
||
if (userInfo.roomInfo.type == RoomType_Anchor && userInfo.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {
|
||
[array removeAllObjects];
|
||
}
|
||
[[self getView] onGetMicroFunctionArraySuccess:array];
|
||
}];
|
||
}
|
||
}];
|
||
}
|
||
}
|
||
|
||
/// 关注用户 /取消该关注
|
||
/// @param targetUid 目标用户的uid
|
||
/// @param status 是否关注 yes 关注 NO 取消关注
|
||
- (void)attentionUser:(NSString *)targetUid status:(BOOL)status {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
||
NSString * type = status ? @"1" : @"2";
|
||
[Api attentionCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
self.attentionItem.isSelect = status;
|
||
[[self getView] attentionUserSuccess:self.attentionItem];
|
||
}] uid:uid likedUid:targetUid ticket:ticket type:type];
|
||
}
|
||
|
||
|
||
/// 加入黑名单
|
||
/// @param targetUid 目标用户的uid
|
||
/// @param roomId 房间的uid
|
||
- (void)makeUserBlack:(NSString *)targetUid roomId:(NSString *)roomId{
|
||
NIMChatroomMemberUpdateRequest *request = [[NIMChatroomMemberUpdateRequest alloc]init];
|
||
request.roomId = roomId;
|
||
request.userId = targetUid;
|
||
request.enable = YES;
|
||
[[NIMSDK sharedSDK].chatroomManager updateMemberBlack:request completion:^(NSError * _Nullable error) {
|
||
[[self getView] makeUserBlackFinish:error];
|
||
}];
|
||
}
|
||
|
||
|
||
/// 设置/取消 管理员
|
||
/// @param targetUid 目标用户的id
|
||
/// @param roomId 房间的id
|
||
/// @param enable YES设置 NO取消
|
||
- (void)makeUserManager:(NSString *)targetUid roomId:(NSString *)roomId enable:(BOOL)enable{
|
||
NIMChatroomMemberUpdateRequest *request = [[NIMChatroomMemberUpdateRequest alloc]init];
|
||
request.roomId = roomId;
|
||
request.userId = targetUid;
|
||
request.enable = enable;
|
||
[[NIMSDK sharedSDK].chatroomManager markMemberManager:request completion:^(NSError * _Nullable error) {
|
||
if (error == nil) {
|
||
self.managerItem.isSelect = enable;
|
||
}
|
||
[[self getView] markUserManagerFinish:self.managerItem error:error];
|
||
}];
|
||
}
|
||
|
||
|
||
/// 踢出房间
|
||
/// @param targetUid 用户的uid
|
||
/// @param roomId 房间的uid
|
||
- (void)makeKickUser:(NSString *)targetUid roomId:(NSString *)roomId {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NIMChatroomMemberKickRequest *request = [[NIMChatroomMemberKickRequest alloc] init];
|
||
request.roomId = roomId;
|
||
request.userId = targetUid;
|
||
if(targetUid != nil && uid != nil){
|
||
request.notifyExt = [@{@"reason":@"kick",@"account":targetUid,@"handleUid":uid} toJSONString];
|
||
}
|
||
[[NIMSDK sharedSDK].chatroomManager kickMember:request completion:^(NSError * _Nullable error) {
|
||
|
||
|
||
[[self getView] makeKickUserFinish:error uid:targetUid];
|
||
}];
|
||
}
|
||
|
||
/// 超管踢管理员
|
||
/// @param targetNick 目标用户的昵称
|
||
/// @param cardInfo 用户信息
|
||
- (void)superAdminKickUser:(NSString *)targetNick cardInfo:(XPUserCardInfoModel *)cardInfo {
|
||
NSString * targetUid = cardInfo.uid;
|
||
NSString * roomId = [NSString stringWithFormat:@"%ld", cardInfo.roomInfo.roomId];
|
||
[[self rac_queryChatRoomMember:targetUid roomId:roomId] subscribeNext:^(id _Nullable x) {
|
||
NIMChatroomMember * member = x;
|
||
if (member == nil) {return;}
|
||
if (member.type == NIMChatroomMemberTypeManager) {
|
||
XPKickUserModel *notifyModel = [[XPKickUserModel alloc] init];
|
||
notifyModel.handleNick = cardInfo.nick;
|
||
notifyModel.handleUid = [AccountInfoStorage instance].getUid.integerValue;
|
||
notifyModel.targetUid = cardInfo.uid.integerValue;
|
||
notifyModel.targetNick = targetNick;
|
||
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
||
attachment.first = CustomMessageType_Hall_Super_Admin;
|
||
attachment.second = Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room;
|
||
attachment.data = [notifyModel model2dictionary];
|
||
NSString * sessionId = [NSString stringWithFormat:@"%ld", cardInfo.roomInfo.roomId];
|
||
NIMMessage *message = [[NIMMessage alloc]init];
|
||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||
object.attachment = attachment;
|
||
message.messageObject = object;
|
||
//构造会话
|
||
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
|
||
NSError * error;
|
||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:&error];
|
||
[[self getView] superAdminKickUserFinish:error];
|
||
} else {
|
||
[self makeKickUser:cardInfo.uid roomId:roomId];
|
||
}
|
||
}];
|
||
}
|
||
|
||
/// 闭麦 开麦
|
||
/// @param roomUid 房间的uid
|
||
/// @param state NO 开麦 YES 闭麦
|
||
/// @param position 操作的坑位
|
||
- (void)microMute:(NSString *)roomUid state:(BOOL)state position:(NSString *)position {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
||
NSString * stateStr = state ? @"1" : @"0";
|
||
[Api microMuteCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
[[self getView] muteMicroSusccess];
|
||
}] roomUid:roomUid state:stateStr position:position ticket:ticket uid:uid];
|
||
}
|
||
|
||
// 锁麦 开锁
|
||
/// @param roomUid 房间的uid
|
||
/// @param state YES 锁坑位,NO取消锁
|
||
/// @param position 操作的坑位
|
||
- (void)microLock:(NSString *)roomUid state:(BOOL)state position:(NSString *)position {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
||
NSString * stateStr = state ? @"1" : @"0";
|
||
[Api microLockCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
[[self getView] lockMicroSusccess];
|
||
}] roomUid:roomUid state:stateStr position:position ticket:ticket uid:uid];
|
||
}
|
||
|
||
/// 抱下麦
|
||
/// @param position 坑位信息
|
||
/// @param roomId 房间id
|
||
- (void)kickDownMicro:(NSString *)position roomId:(NSString *)roomId {
|
||
NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init];
|
||
request.key = position;
|
||
request.roomId = roomId;
|
||
[[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary<NSString *,NSString *> * _Nullable element) {
|
||
if (error == nil ) {
|
||
[[self getView] kickDownMicroSuccess];
|
||
}
|
||
}];
|
||
}
|
||
|
||
|
||
/// 抱她上麦
|
||
/// @param roomId 房间的id
|
||
/// @param position 抱到几号坑
|
||
/// @param userInfo 用户信息
|
||
- (void)upMicro:(NSString *)roomId position:(NSString *)position userInfo:(UserInfoModel *)userInfo {
|
||
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
|
||
request.key = position;
|
||
request.value = [userInfo toJSONString];
|
||
request.roomId = roomId;
|
||
request.transient = YES;
|
||
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
|
||
if (error == nil) {
|
||
[[self getView] upMicroSuccess];
|
||
}
|
||
}];
|
||
}
|
||
|
||
|
||
/// 清除用户的礼物值
|
||
/// @param roomUid 房间的uid
|
||
/// @param micUid 被清除的uid
|
||
- (void)cleanUserGiftValue:(NSString *)roomUid micUid:(NSString *)micUid {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
[Api cleanMicroGiftValue:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
[[self getView] cleanUserGiftValueSuccess:data.data];
|
||
}] roomUid:roomUid micUid:micUid uid:uid];
|
||
}
|
||
|
||
|
||
/// 心动选人
|
||
/// @param roomUid 房主的uid
|
||
/// @param chosenUserId 被选择的uid
|
||
- (void)pickHeartUser:(NSString *)roomUid chosenUserId:(NSString *)chosenUserId {
|
||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||
[Api roomDatingPickUser:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
[[self getView] roomDatingPickHeartUserSuccess];
|
||
}] roomUserId:roomUid chosenUserId:chosenUserId electorUserId:uid];
|
||
}
|
||
|
||
|
||
/// 超管处理用户
|
||
/// @param targetUid 目标用户的uid
|
||
/// @param opt 1: 设置为管理员;2:设置普通等级用户;-1:设为黑名单用户;-2:设为禁言用户
|
||
/// @param roomUid 房主的uid
|
||
- (void)superAdminHandleUser:(NSString *)targetUid opt:(NSString *)opt roomUid:(NSString *)roomUid isSet:(BOOL)isSet{
|
||
[Api superAdminHandleUser:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
[[self getView] superAdminHandleUserSuccess:opt];
|
||
}] roomUid:roomUid targetUid:targetUid opt:opt isSet:@(isSet)];
|
||
}
|
||
|
||
#pragma mark - Private Method
|
||
///获取房间角色
|
||
- (RACSignal *)rac_queryChatRoomMember:(NSString *)uid roomId:(NSString *)roomId{
|
||
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
|
||
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
|
||
request.roomId = roomId;
|
||
if(uid != nil){
|
||
request.userIds = @[uid];
|
||
}
|
||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
|
||
if (error == nil) {
|
||
[subscriber sendNext:members.firstObject];
|
||
[subscriber sendCompleted];
|
||
}else {
|
||
[subscriber sendNext:nil];
|
||
[subscriber sendCompleted];
|
||
}
|
||
}];
|
||
return nil;
|
||
}];
|
||
}
|
||
/// 记录踢人名单列表
|
||
/// @param roomUid 房间id
|
||
/// @param uid 用户id
|
||
-(void)recordsKickUserListWithRoomUid:(NSString *)roomUid uid:(NSString *)uid{
|
||
[Api recordskickUserList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||
|
||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||
|
||
} showLoading:NO errorToast:NO] roomUid:roomUid uid:uid ];
|
||
}
|
||
#pragma mark - Getters And Setters
|
||
- (NSMutableArray *)functionArray {
|
||
if (!_functionArray) {
|
||
_functionArray = [NSMutableArray array];
|
||
}
|
||
return _functionArray;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)giftItem {
|
||
if (!_giftItem) {
|
||
_giftItem = [[XPUserCardItemModel alloc] init];
|
||
_giftItem.title = YMLocalizedString(@"XPUserCardPresenter13");
|
||
_giftItem.imageName = @"usercard_sendgift_normal";
|
||
_giftItem.selectImageName = @"usercard_sendgift_normal";
|
||
_giftItem.type = UserCardItemType_Gift;
|
||
}
|
||
return _giftItem;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)chatItem {
|
||
if (!_chatItem) {
|
||
_chatItem = [[XPUserCardItemModel alloc] init];
|
||
_chatItem.title = YMLocalizedString(@"XPUserCardPresenter14");
|
||
_chatItem.imageName = @"usercard_chat_normal";
|
||
_chatItem.selectImageName = @"usercard_chat_normal";
|
||
_chatItem.type = UserCardItemType_Chat;
|
||
}
|
||
return _chatItem;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)atItem {
|
||
if (!_atItem) {
|
||
_atItem = [[XPUserCardItemModel alloc] init];
|
||
_atItem.title = @"@TA";
|
||
_atItem.imageName = @"usercard_chat_normal";
|
||
_atItem.selectImageName = @"usercard_chat_normal";
|
||
_atItem.type = UserCardItemType_AtUser;
|
||
}
|
||
return _atItem;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)attentionItem {
|
||
if (!_attentionItem) {
|
||
_attentionItem = [[XPUserCardItemModel alloc] init];
|
||
_attentionItem.title = YMLocalizedString(@"StageView29");
|
||
_attentionItem.imageName = @"usercard_attention_normal";
|
||
_attentionItem.selectTitle = YMLocalizedString(@"XPUserCardPresenter16");
|
||
_attentionItem.selectImageName = @"usercard_attention_disable";
|
||
_attentionItem.type = UserCardItemType_Attention;
|
||
}
|
||
return _attentionItem;
|
||
}
|
||
|
||
- ( XPUserCardItemModel *)kikoutItem {
|
||
if (!_kikoutItem) {
|
||
_kikoutItem = [[XPUserCardItemModel alloc] init];
|
||
_kikoutItem.title = YMLocalizedString(@"XPUserCardPresenter17");
|
||
_kikoutItem.imageName = @"usercard_kickout_normal";
|
||
_kikoutItem.selectImageName = @"usercard_kickout_normal";
|
||
_kikoutItem.type = UserCardItemType_KickOut;
|
||
}
|
||
return _kikoutItem;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)managerItem {
|
||
if (!_managerItem) {
|
||
_managerItem = [[XPUserCardItemModel alloc] init];
|
||
_managerItem.title = YMLocalizedString(@"XPUserCardPresenter18");
|
||
_managerItem.imageName = @"usercard_manager_normal";
|
||
_managerItem.selectTitle = YMLocalizedString(@"XPUserCardPresenter19");
|
||
_managerItem.selectImageName = @"usercard_manager_disable";
|
||
_managerItem.type = UserCardItemType_Manager;
|
||
}
|
||
return _managerItem;
|
||
}
|
||
|
||
- (XPUserCardItemModel *)blackItem {
|
||
if (!_blackItem) {
|
||
_blackItem = [[XPUserCardItemModel alloc] init];
|
||
_blackItem.title = YMLocalizedString(@"XPUserCardPresenter20");
|
||
_blackItem.imageName = @"usercard_blacklist_normal";
|
||
_blackItem.type = UserCardItemType_Black;
|
||
}
|
||
return _blackItem;
|
||
}
|
||
|
||
@end
|