Browse Source

group manager

heavyrain2012 5 years ago
parent
commit
89af2de0ae

+ 1 - 0
wfclient/WFChatClient/Client/WFCCIMService.h

@@ -750,6 +750,7 @@ typedef NS_ENUM(NSInteger, UserSettingScope) {
 - (void)createGroup:(NSString *)groupId
                name:(NSString *)groupName
            portrait:(NSString *)groupPortrait
+               type:(WFCCGroupType)type
             members:(NSArray *)groupMembers
         notifyLines:(NSArray<NSNumber *> *)notifyLines
       notifyContent:(WFCCMessageContent *)notifyContent

+ 2 - 1
wfclient/WFChatClient/Client/WFCCIMService.mm

@@ -1192,6 +1192,7 @@ WFCCGroupInfo *convertProtoGroupInfo(mars::stn::TGroupInfo tgi) {
 - (void)createGroup:(NSString *)groupId
                name:(NSString *)groupName
            portrait:(NSString *)groupPortrait
+               type:(WFCCGroupType)type
             members:(NSArray *)groupMembers
         notifyLines:(NSArray<NSNumber *> *)notifyLines
       notifyContent:(WFCCMessageContent *)notifyContent
@@ -1209,7 +1210,7 @@ WFCCGroupInfo *convertProtoGroupInfo(mars::stn::TGroupInfo tgi) {
     for (NSNumber *number in notifyLines) {
         lines.push_back([number intValue]);
     }
-    mars::stn::createGroup(groupId == nil ? "" : [groupId UTF8String], groupName == nil ? "" : [groupName UTF8String], groupPortrait == nil ? "" : [groupPortrait UTF8String], memberList, lines, tcontent, new IMCreateGroupCallback(successBlock, errorBlock));
+    mars::stn::createGroup(groupId == nil ? "" : [groupId UTF8String], groupName == nil ? "" : [groupName UTF8String], groupPortrait == nil ? "" : [groupPortrait UTF8String], type, memberList, lines, tcontent, new IMCreateGroupCallback(successBlock, errorBlock));
 }
 
 - (void)addMembers:(NSArray *)members

+ 1 - 1
wfclient/WFChatClient/Model/WFCCGroupInfo.h

@@ -67,7 +67,7 @@ typedef NS_ENUM(NSInteger, WFCCGroupType) {
 @property (nonatomic, assign)int mute;
 
 /**
- 加群申请状态,0 无需验证;1 需要验证
+ 加群申请状态,0 不限制加入(用户可以自己加群或被普通群成员拉入);1 普通群成员可以拉人进群;2 只有群管理才能拉人
  */
 @property (nonatomic, assign)int joinType;
 

+ 1 - 1
wfclient/WFChatClient/Proto/mars.framework/Headers/comm/verinfo.h

@@ -2,7 +2,7 @@
 #ifndef Mars_verinfo_h
 #define Mars_verinfo_h
 
-#define MARS_REVISION "24d7601"
+#define MARS_REVISION "3a649b4"
 #define MARS_PATH "firechat"
 #define MARS_URL ""
 #define MARS_BUILD_TIME "2019-06-29 18:46:43"

+ 1 - 1
wfclient/WFChatClient/Proto/mars.framework/Headers/proto/proto.h

@@ -643,7 +643,7 @@ namespace mars{
         
         extern void blackListRequest(const std::string &userId, bool blacked, GeneralOperationCallback *callback);
         
-        extern void (*createGroup)(const std::string &groupId, const std::string &groupName, const std::string &groupPortrait, const std::list<std::string> &groupMembers, const std::list<int> &notifyLines, TMessageContent &content, CreateGroupCallback *callback);
+        extern void (*createGroup)(const std::string &groupId, const std::string &groupName, const std::string &groupPortrait, int groupType, const std::list<std::string> &groupMembers, const std::list<int> &notifyLines, TMessageContent &content, CreateGroupCallback *callback);
         
         extern void (*addMembers)(const std::string &groupId, const std::list<std::string> &members, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
         

BIN
wfclient/WFChatClient/Proto/mars.framework/mars


+ 32 - 5
wfuikit/WFChatUIKit/ConversationSetting/ViewController/GroupManageTableViewController.m

@@ -10,6 +10,7 @@
 #import "ManagerTableViewController.h"
 #import "GroupMuteTableViewController.h"
 #import "GroupMemberControlTableViewController.h"
+#import "UIView+Toast.h"
 
 @interface GroupManageTableViewController () <UITableViewDelegate, UITableViewDataSource>
 @property(nonatomic, strong)UITableView *tableView;
@@ -66,7 +67,13 @@
     } else if(indexPath.section == 1) {
         if (indexPath.row == 0) {
             cell.textLabel.text = @"加群方式";
-            cell.detailTextLabel.text = @"需要验证加入";
+            if (self.groupInfo.joinType == 0) {
+                cell.detailTextLabel.text = @"不限制加入";
+            } else if(self.groupInfo.joinType == 1) {
+                cell.detailTextLabel.text = @"群成员可以拉人";
+            } else if(self.groupInfo.joinType == 2) {
+                cell.detailTextLabel.text = @"只能群管理拉人";
+            }
         } else if(indexPath.row == 1) {
             cell.textLabel.text = @"查找方式";
             cell.detailTextLabel.text = @"不允许查找";
@@ -147,16 +154,36 @@
             }];
             [alertController addAction:cancelAction];
             
-            UIAlertAction *openAction = [UIAlertAction actionWithTitle:@"不需要验证" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-                
+            UIAlertAction *openAction = [UIAlertAction actionWithTitle:@"不限制加入" style:self.groupInfo.joinType == 0 ? UIAlertActionStyleDestructive : UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                [[WFCCIMService sharedWFCIMService] modifyGroupInfo:self.groupInfo.target type:Modify_Group_JoinType newValue:@"0" notifyLines:@[@(0)] notifyContent:nil success:^{
+                    self.groupInfo.joinType = 0;
+                    [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
+                } error:^(int error_code) {
+                    [self.view makeToast:@"设置失败"];
+                }];
             }];
             [alertController addAction:openAction];
             
-            UIAlertAction *verifyAction = [UIAlertAction actionWithTitle:@"需要验证加入" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-                
+            UIAlertAction *verifyAction = [UIAlertAction actionWithTitle:@"群成员可以拉人" style:self.groupInfo.joinType == 1 ? UIAlertActionStyleDestructive : UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                [[WFCCIMService sharedWFCIMService] modifyGroupInfo:self.groupInfo.target type:Modify_Group_JoinType newValue:@"1" notifyLines:@[@(0)] notifyContent:nil success:^{
+                    self.groupInfo.joinType = 1;
+                    [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
+                } error:^(int error_code) {
+                    [self.view makeToast:@"设置失败"];
+                }];
             }];
             [alertController addAction:verifyAction];
             
+            UIAlertAction *normalAction = [UIAlertAction actionWithTitle:@"只能群管理拉人" style:self.groupInfo.joinType == 2 ? UIAlertActionStyleDestructive : UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                [[WFCCIMService sharedWFCIMService] modifyGroupInfo:self.groupInfo.target type:Modify_Group_JoinType newValue:@"2" notifyLines:@[@(0)] notifyContent:nil success:^{
+                    self.groupInfo.joinType = 2;
+                    [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
+                } error:^(int error_code) {
+                    [self.view makeToast:@"设置失败"];
+                }];
+            }];
+            [alertController addAction:normalAction];
+            
             [self.navigationController presentViewController:alertController animated:YES completion:nil];
         } else if(indexPath.row == 1) {
             UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"查找方式" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

+ 23 - 1
wfuikit/WFChatUIKit/ConversationSetting/ViewController/WFCUConversationSettingViewController.m

@@ -25,6 +25,7 @@
 #import "WFCUConversationSearchTableViewController.h"
 #import "WFCUChannelProfileViewController.h"
 #import "QrCodeHelper.h"
+#import "UIView+Toast.h"
 
 @interface WFCUConversationSettingViewController () <UITableViewDataSource, UITableViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource>
 @property (nonatomic, strong)UICollectionView *memberCollectionView;
@@ -70,7 +71,17 @@
         if (self.conversation.type == Single_Type) {
             memberCollectionCount = 2;
         } else if(self.conversation.type == Group_Type) {
-            memberCollectionCount = [self isGroupManager] ? (int)self.memberList.count + 2 : (int)self.memberList.count + 1;
+            if ([self isGroupManager]) {
+                memberCollectionCount = (int)self.memberList.count + 2;
+            } else if(self.groupInfo.type == GroupType_Restricted) {
+                if (self.groupInfo.joinType == 1 || self.groupInfo.joinType == 0) {
+                    memberCollectionCount = (int)self.memberList.count + 1;
+                } else {
+                    memberCollectionCount = (int)self.memberList.count;
+                }
+            } else {
+                memberCollectionCount = (int)self.memberList.count + 1;
+            }
         } else if(self.conversation.type == Channel_Type) {
             memberCollectionCount = 1;
         }
@@ -533,6 +544,10 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     __weak typeof(self)weakSelf = self;
   if ([self isGroupNameCell:indexPath]) {
+      if (self.groupInfo.type == GroupType_Restricted && ![self isGroupManager]) {
+          [self.view makeToast:@"只有管理员才可以修改群名称" duration:1 position:CSToastPositionCenter];
+          return;
+      }
     WFCUGeneralModifyViewController *gmvc = [[WFCUGeneralModifyViewController alloc] init];
     gmvc.defaultValue = self.groupInfo.name;
     gmvc.titleText = @"修改群名称";
@@ -547,6 +562,10 @@
     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:gmvc];
     [self.navigationController presentViewController:nav animated:YES completion:nil];
   } else if ([self isGroupPortraitCell:indexPath]) {
+      if (self.groupInfo.type == GroupType_Restricted && ![self isGroupManager]) {
+          [self.view makeToast:@"只有管理员才可以修改群头像" duration:1 position:CSToastPositionCenter];
+          return;
+      }
     WFCUCreateGroupViewController *vc = [[WFCUCreateGroupViewController alloc] init];
     vc.isModifyPortrait = YES;
     vc.groupId = self.groupInfo.target;
@@ -627,6 +646,9 @@
         if([self isGroupManager]) {
             return self.memberList.count + 2;
         } else {
+            if (self.groupInfo.type == GroupType_Restricted && self.groupInfo.joinType != 1 && self.groupInfo.joinType != 0) {
+                return self.memberList.count;
+            }
             return self.memberList.count + 1;
         }
     } else if(self.conversation.type == Single_Type) {

+ 10 - 2
wfuikit/WFChatUIKit/CreateGroup/ViewController/WFCUCreateGroupViewController.m

@@ -19,7 +19,7 @@
 @property(nonatomic, strong)NSString *portraitUrl;
 
 @property(nonatomic, strong)UIButton *resetBtn;
-  
+@property(nonatomic, strong)UISwitch *qqSwitch;
 @property(nonatomic, strong)UIView *combineHeadView;
 @end
 #define PortraitWidth 120
@@ -70,6 +70,14 @@
     UIView *line = [[UIView alloc] initWithFrame:CGRectMake(namePadding, 80 + portraitWidth + 60 + 24, bound.size.width - namePadding - namePadding, 2)];
     [line setBackgroundColor:[UIColor grayColor]];
     [self.view addSubview:line];
+      
+      UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(namePadding, 80 + portraitWidth + 60 + 24 + 40, 80, 24)];
+      label.text = @"QQ风格";
+      [self.view addSubview:label];
+      
+      self.qqSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(namePadding + 84, 80 + portraitWidth + 60 + 24 + 40, 60, 24)];
+      self.qqSwitch.on = NO;
+      [self.view addSubview:self.qqSwitch];
   }
     
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(onDone:)];
@@ -284,7 +292,7 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info {
   
 - (void)createGroup:(NSString *)groupName portrait:(NSString *)portraitUrl members:(NSArray<NSString *> *)memberIds {
     __weak typeof(self) ws = self;
-    [[WFCCIMService sharedWFCIMService] createGroup:nil name:groupName portrait:portraitUrl members:memberIds notifyLines:@[@(0)] notifyContent:nil success:^(NSString *groupId) {
+    [[WFCCIMService sharedWFCIMService] createGroup:nil name:groupName portrait:portraitUrl type:self.qqSwitch.on ? GroupType_Restricted : GroupType_Normal members:memberIds notifyLines:@[@(0)] notifyContent:nil success:^(NSString *groupId) {
         NSLog(@"create group success");
         if (ws.onSuccess) {
             dispatch_async(dispatch_get_main_queue(), ^{