127 lines
4.9 KiB
Objective-C
127 lines
4.9 KiB
Objective-C
//
|
|
// MessagePresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by zu on 2021/12/8.
|
|
//
|
|
|
|
#import "MessagePresenter.h"
|
|
#import "Api+Message.h"
|
|
#import "ChatLimitModel.h"
|
|
#import "MessageProtocol.h"
|
|
#import "Api+Mine.h"
|
|
#import "UserInfoModel.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "NIMMessageUtils.h"
|
|
#import "XPMessageRemoteExtModel.h"
|
|
|
|
@implementation MessagePresenter
|
|
|
|
// 获取用户信息
|
|
- (void)getUserInfoWithUid:(NSString *)uid {
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetUserInfoSuccess:infoModel];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
}] uid:uid];
|
|
}
|
|
|
|
- (void)getChatLimitReceiverUid:(NSString *)receiverUid {
|
|
[Api getChatLimit:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
ChatLimitModel *chatLimit = [ChatLimitModel modelWithJSON:data.data];
|
|
[[self getView] onGetLimitChat:chatLimit];
|
|
} showLoading:NO errorToast:NO] receiverUid:receiverUid];
|
|
}
|
|
|
|
/// 获取用户信息
|
|
/// @param uid 用户uid
|
|
- (void)getUserInfo:(NSString *)uid {
|
|
[Api userDetailInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetSessionUserInfoSuccess:infoModel];
|
|
}] uid:uid page:@"1" pageSize:@"20"];
|
|
}
|
|
|
|
///是否关注当前用户
|
|
- (void)getFansLike:(NSString *)likeUid {
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
[Api attentionStatusCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
BOOL isLike = [data.data boolValue] || [NIMMessageUtils isOfficalAccount:likeUid];
|
|
[[self getView] getFansLikeSuccess:isLike];
|
|
}] uid:uid isLikeUid:likeUid];
|
|
}
|
|
|
|
/// 关注用户
|
|
/// @param targetUid 目标用户的uid
|
|
- (void)attentionUser:(NSString *)targetUid {
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
|
NSString * type = @"1";
|
|
[Api attentionCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] attentionUserSuccess:targetUid];
|
|
} showLoading:YES] uid:uid likedUid:targetUid ticket:ticket type:type];
|
|
}
|
|
- (void)enterNIMRoom:(NSString *)roomId user:(UserInfoModel *)userInfo {
|
|
NIMChatroomEnterRequest *request = [[NIMChatroomEnterRequest alloc] init];
|
|
request.roomId = roomId;
|
|
//设置ext
|
|
XPMessageRemoteExtModel * extModel = [[XPMessageRemoteExtModel alloc] init];
|
|
extModel.defUser = userInfo.defUser;
|
|
extModel.erbanNo = userInfo.erbanNo;
|
|
extModel.carName = userInfo.carName;
|
|
extModel.inRoomNameplatePic = userInfo.nameplatePic;
|
|
extModel.inRoomNameplateWord = userInfo.nameplateWord;
|
|
extModel.isCustomWord = userInfo.isCustomWord;
|
|
extModel.charmUrl = userInfo.userLevelVo.charmUrl;
|
|
extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq;
|
|
extModel.experUrl = userInfo.userLevelVo.experUrl;
|
|
extModel.newUser = userInfo.newUser;
|
|
extModel.vipIcon = userInfo.userVipInfoVO.vipIcon;
|
|
extModel.fromUid = userInfo.fromUid;
|
|
extModel.fromType = userInfo.fromType;
|
|
extModel.fromNick = userInfo.fromNick;
|
|
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
|
|
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
|
|
extModel.enterHide = userInfo.userVipInfoVO.enterHide;
|
|
extModel.preventKick = userInfo.userVipInfoVO.preventKick;
|
|
extModel.enterRoomEffects = userInfo.userVipInfoVO.enterRoomEffects;
|
|
extModel.gender = userInfo.gender;
|
|
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
|
|
extModel.platformRole = userInfo.platformRole;
|
|
|
|
NSMutableDictionary *ext = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
|
|
request.roomExt = [ext toJSONString];
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager enterChatroom:request completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) {
|
|
if (error) {
|
|
[[self getView] enterPublicChatHallFail:error.code];
|
|
} else {
|
|
[[self getView] enterPublicChatHallSuccess:chatroom];
|
|
}
|
|
}];
|
|
}
|
|
|
|
- (void)exitNIMRoom:(NSString *)roomId {
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil];
|
|
}
|
|
///聊天室发送头条
|
|
-(void)sendPublicChatHallTopTextWithcontent:(NSString *)content{
|
|
[Api sendPublicChatHallTopText:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
|
|
} showLoading:YES errorToast:YES] content:content];
|
|
}
|
|
///获取聊天室发送头条
|
|
-(void)getPublicChatHallTopText{
|
|
[Api getPublicChatHallTopText:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
|
|
}]];
|
|
}
|
|
///获取聊天室数据
|
|
-(void)getPublicChatHallList{
|
|
[Api getPublicChatHallList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
}];
|
|
}
|
|
@end
|