From 367aee0b532decbde0e3ffa8021481fd33a7e2e3 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Mon, 15 Aug 2022 18:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E9=99=A9=E6=8F=90=E9=86=92=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios/Global/XPHtmlUrl.h | 4 ++- xplan-ios/Global/XPHtmlUrl.m | 1 + .../Content/MessageContentRiskAlertView.m | 31 ++++++++++++++----- .../View/Session/Content/MessageContentText.m | 3 +- .../Main/Message/View/Session/MessageCell.m | 6 ++++ .../View/Session/SessionViewController.m | 9 ++++++ .../Main/Room/View/XPRoomViewController.m | 10 ++++++ 7 files changed, 55 insertions(+), 9 deletions(-) diff --git a/xplan-ios/Global/XPHtmlUrl.h b/xplan-ios/Global/XPHtmlUrl.h index 2f831d99..ab19221e 100644 --- a/xplan-ios/Global/XPHtmlUrl.h +++ b/xplan-ios/Global/XPHtmlUrl.h @@ -75,7 +75,9 @@ typedef NS_ENUM(NSUInteger, URLType) { ///航海玩法说明 kSailingPlayDescdURL, ///活动地址 - kSailingActivityURL + kSailingActivityURL, + ///网络整治乱象 + kNetworkRenovateURL }; NSString * const URLWithType(URLType type); diff --git a/xplan-ios/Global/XPHtmlUrl.m b/xplan-ios/Global/XPHtmlUrl.m index b0dcdd08..ab325c96 100644 --- a/xplan-ios/Global/XPHtmlUrl.m +++ b/xplan-ios/Global/XPHtmlUrl.m @@ -50,6 +50,7 @@ NSString * const URLWithType(URLType type) { @(kSailingActivityURL) : @"activity/radish/index.html", ///航海活动地址 @(kSailingPlayDescdURL) : @"modules/rule/radishRule.html", ///航海玩法规则 @(kSailingRecordURL) : @"modules/rank/index.html#/RadishRecord", ///航海中奖记录 + @(kNetworkRenovateURL) : @"activity/activemodel/index.html?code=ZBGG"///网络整治乱象 }; NSString * url = [dic objectForKey:@(type)]; diff --git a/xplan-ios/Main/Message/View/Session/Content/MessageContentRiskAlertView.m b/xplan-ios/Main/Message/View/Session/Content/MessageContentRiskAlertView.m index 2bd5a635..9963820f 100644 --- a/xplan-ios/Main/Message/View/Session/Content/MessageContentRiskAlertView.m +++ b/xplan-ios/Main/Message/View/Session/Content/MessageContentRiskAlertView.m @@ -8,13 +8,17 @@ #import "MessageContentRiskAlertView.h" ///Third #import +#import #import "ContentRistAlertModel.h" #import "NSObject+MJExtension.h" #import "ThemeColor.h" +#import "XCCurrentVCStackManager.h" +#import "XPHtmlUrl.h" +#import "XPWebViewController.h" @interface MessageContentRiskAlertView () ///显示内容 -@property (nonatomic,strong) UILabel *contentLabel; +@property (nonatomic,strong) YYLabel *contentLabel; @end @implementation MessageContentRiskAlertView @@ -44,9 +48,9 @@ - (void)initSubViews { [super initSubViews]; - self.backView.backgroundColor = [ThemeColor colorWithHexString:@"#e8e8e8"]; - self.backView.layer.masksToBounds = YES; - self.backView.layer.cornerRadius = 10; +// self.backView.backgroundColor = [ThemeColor colorWithHexString:@"#e8e8e8"]; +// self.backView.layer.masksToBounds = YES; +// self.backView.layer.cornerRadius = 10; [self.backView addSubview:self.contentLabel]; } @@ -66,12 +70,25 @@ if (text.length <= 0) { text = @""; } - self.contentLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:text attributes:[MessageContentRiskAlertView messageTextAttibutes]]; + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:text attributes:[MessageContentRiskAlertView messageTextAttibutes]]; + NSRange range = [text rangeOfString:@"《整治网络直播乱象》"]; + if ((range.location + range.length) <= text.length) { + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appEmphasizeColor] range:range]; + + } + + [attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { + XPWebViewController * webVC = [[XPWebViewController alloc] init]; + webVC.url = URLWithType(kNetworkRenovateURL); + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + }]; + self.contentLabel.attributedText = attribute; + } -- (UILabel *)contentLabel { +- (YYLabel *)contentLabel { if (!_contentLabel) { - _contentLabel = [[UILabel alloc]initWithFrame:CGRectZero]; + _contentLabel = [[YYLabel alloc]initWithFrame:CGRectZero]; _contentLabel.preferredMaxLayoutWidth = CONTENT_WIDTH_MAX - MESSAGE_PADDING * 2; _contentLabel.textColor = ThemeColor.mainTextColor; _contentLabel.numberOfLines = 0; diff --git a/xplan-ios/Main/Message/View/Session/Content/MessageContentText.m b/xplan-ios/Main/Message/View/Session/Content/MessageContentText.m index 579d2161..8229c048 100644 --- a/xplan-ios/Main/Message/View/Session/Content/MessageContentText.m +++ b/xplan-ios/Main/Message/View/Session/Content/MessageContentText.m @@ -7,6 +7,7 @@ #import "MessageContentText.h" #import "ThemeColor.h" +#import "NSObject+MJExtension.h" #import #import @@ -63,7 +64,7 @@ if (!messageText || (message.messageType != NIMMessageTypeTip && message.messageType != NIMMessageTypeText)) { messageText = @"未知消息类型"; } - + NSDictionary * dic = message.yidunAntiSpamRes.toJSONObject; _messageText.attributedText = [[NSAttributedString alloc] initWithString:messageText attributes:[MessageContentText messageTextAttibutes]]; } diff --git a/xplan-ios/Main/Message/View/Session/MessageCell.m b/xplan-ios/Main/Message/View/Session/MessageCell.m index e2522ad3..7fb10410 100644 --- a/xplan-ios/Main/Message/View/Session/MessageCell.m +++ b/xplan-ios/Main/Message/View/Session/MessageCell.m @@ -199,6 +199,12 @@ BOOL isHiddenFail = YES; if (!message.isReceivedMsg) { isHiddenFail = message.deliveryState != NIMMessageDeliveryStateFailed; + if (message.localExt) { + NSDictionary * dic = message.localExt; + if (((NSString *)dic[@"suggestion"]).integerValue == 2) { + isHiddenFail = NO; + } + } } else { isHiddenFail = message.attachmentDownloadState != NIMMessageAttachmentDownloadStateFailed; } diff --git a/xplan-ios/Main/Message/View/Session/SessionViewController.m b/xplan-ios/Main/Message/View/Session/SessionViewController.m index 0c396b80..3a1ce849 100644 --- a/xplan-ios/Main/Message/View/Session/SessionViewController.m +++ b/xplan-ios/Main/Message/View/Session/SessionViewController.m @@ -380,6 +380,15 @@ if (![self isExistMessages:message]) { [self.messages addObject:message]; } + + if (message.yidunAntiSpamRes) { + NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject; + NSDictionary * spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject; + if ([spamResExt[@"antispam"][@"suggestion"] intValue] == 2) { + NSDictionary * dic = @{@"suggestion": @"2"}; + message.localExt = dic; + } + } [self.sessionTableView reloadData]; [self.sessionTableView nim_scrollToBottom:YES]; } diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index f57a16f5..c8e94958 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -1165,6 +1165,16 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { return; } + + if (message.yidunAntiSpamRes) { + NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject; + NSDictionary * spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject; + if ([spamResExt[@"antispam"][@"suggestion"] intValue] == 2) { + [self showErrorToast:@"消息中可能含有违规信息,请停止发送类似信息!"]; + return; + } + } + if (error) return; if (message.messageType == NIMMessageTypeCustom) { NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;