@ -124,21 +124,64 @@ NS_ASSUME_NONNULL_BEGIN
__weak ShowGroupMembersViewController * weakSelf = self ;
__weak ShowGroupMembersViewController * weakSelf = self ;
ContactsViewHelper * helper = self . contactsViewHelper ;
ContactsViewHelper * helper = self . contactsViewHelper ;
OWSTableSection * membersSection = [ OWSTableSection new ] ;
/ / Group Members
/ / Group Members
OWSTableSection * section = [ OWSTableSection new ] ;
/ / If there are "no longer verified " members of the group ,
/ / highlight them in a special section .
NSArray < NSString * > * noLongerVerifiedRecipientIds = [ self noLongerVerifiedRecipientIds ] ;
if ( noLongerVerifiedRecipientIds . count > 0 ) {
OWSTableSection * noLongerVerifiedSection = [ OWSTableSection new ] ;
noLongerVerifiedSection . headerTitle = NSLocalizedString ( @ "GROUP_MEMBERS_SECTION_TITLE_NO_LONGER_VERIFIED ",
@ "Title for the ' no longer verified' section of the ' group members' view . ") ;
membersSection . headerTitle = NSLocalizedString (
@ "GROUP_MEMBERS_SECTION_TITLE_MEMBERS ", @ "Title for the ' members' section of the ' group members' view . ") ;
[ noLongerVerifiedSection
addItem : [ OWSTableItem disclosureItemWithText : NSLocalizedString ( @ "GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED ",
@ "Label for the button that clears all verification "
@ "errors in the ' group members' view . ")
customRowHeight : ContactTableViewCell . rowHeight
actionBlock : ^{
[ weakSelf offerResetAllNoLongerVerified ] ;
} ] ] ;
[ self addMembers : noLongerVerifiedRecipientIds toSection : noLongerVerifiedSection useVerifyAction : YES ] ;
[ contents addSection : noLongerVerifiedSection ] ;
}
NSMutableSet * memberRecipientIds = [ self . memberRecipientIds mutableCopy ] ;
NSMutableSet * memberRecipientIds = [ self . memberRecipientIds mutableCopy ] ;
[ memberRecipientIds removeObject : [ helper localNumber ] ] ;
[ memberRecipientIds removeObject : [ helper localNumber ] ] ;
for ( NSString * recipientId in [ memberRecipientIds . allObjects sortedArrayUsingSelector : @ selector ( compare : ) ] ) {
[ self addMembers : memberRecipientIds . allObjects toSection : membersSection useVerifyAction : NO ] ;
[ contents addSection : membersSection ] ;
self . contents = contents ;
}
- ( void ) addMembers : ( NSArray < NSString * > * ) recipientIds
toSection : ( OWSTableSection * ) section
useVerifyAction : ( BOOL ) useVerifyAction
{
OWSAssert ( recipientIds ) ;
OWSAssert ( section ) ;
__weak ShowGroupMembersViewController * weakSelf = self ;
ContactsViewHelper * helper = self . contactsViewHelper ;
for ( NSString * recipientId in [ recipientIds sortedArrayUsingSelector : @ selector ( compare : ) ] ) {
[ section addItem : [ OWSTableItem itemWithCustomCellBlock : ^{
[ section addItem : [ OWSTableItem itemWithCustomCellBlock : ^{
ShowGroupMembersViewController * strongSelf = weakSelf ;
ShowGroupMembersViewController * strongSelf = weakSelf ;
OWSAssert ( strongSelf ) ;
OWSAssert ( strongSelf ) ;
ContactTableViewCell * cell = [ ContactTableViewCell new ] ;
ContactTableViewCell * cell = [ ContactTableViewCell new ] ;
SignalAccount * signalAccount = [ helper signalAccountForRecipientId : recipientId ] ;
SignalAccount * signalAccount = [ helper signalAccountForRecipientId : recipientId ] ;
OWSVerificationState verificationState =
[ [ OWSIdentityManager sharedManager ] verificationStateForRecipientId : recipientId ] ;
BOOL isVerified = verificationState == OWSVerificationStateVerified ;
BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified ;
BOOL isBlocked = [ helper isRecipientIdBlocked : recipientId ] ;
BOOL isBlocked = [ helper isRecipientIdBlocked : recipientId ] ;
if ( isBlocked ) {
if ( isNoLongerVerified ) {
cell . accessoryMessage = NSLocalizedString (
@ "CONTACT_CELL_IS_NO_LONGER_VERIFIED ", @ "An indicator that a contact is no longer verified . ") ;
} else if ( isBlocked ) {
cell . accessoryMessage
cell . accessoryMessage
= NSLocalizedString ( @ "CONTACT_CELL_IS_BLOCKED ", @ "An indicator that a contact has been blocked . ") ;
= NSLocalizedString ( @ "CONTACT_CELL_IS_BLOCKED ", @ "An indicator that a contact has been blocked . ") ;
}
}
@ -149,8 +192,6 @@ NS_ASSUME_NONNULL_BEGIN
[ cell configureWithRecipientId : recipientId contactsManager : helper . contactsManager ] ;
[ cell configureWithRecipientId : recipientId contactsManager : helper . contactsManager ] ;
}
}
BOOL isVerified = [ [ OWSIdentityManager sharedManager ] verificationStateForRecipientId : recipientId ]
== OWSVerificationStateVerified ;
if ( isVerified ) {
if ( isVerified ) {
[ cell addVerifiedSubtitle ] ;
[ cell addVerifiedSubtitle ] ;
}
}
@ -159,12 +200,77 @@ NS_ASSUME_NONNULL_BEGIN
}
}
customRowHeight : [ ContactTableViewCell rowHeight ]
customRowHeight : [ ContactTableViewCell rowHeight ]
actionBlock : ^{
actionBlock : ^{
[ weakSelf didSelectRecipientId : recipientId ] ;
if ( useVerifyAction ) {
[ weakSelf showSafetyNumberView : recipientId ] ;
} else {
[ weakSelf didSelectRecipientId : recipientId ] ;
}
} ] ] ;
} ] ] ;
}
}
[ contents addSection : section ] ;
}
self . contents = contents ;
- ( void ) offerResetAllNoLongerVerified
{
OWSAssert ( [ NSThread isMainThread ] ) ;
UIAlertController * actionSheetController = [ UIAlertController
alertControllerWithTitle : nil
message : NSLocalizedString ( @ "GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED_ALERT_MESSAGE ",
@ "Label for the ' reset all no-longer-verified group members' confirmation alert . ")
preferredStyle : UIAlertControllerStyleAlert ] ;
__weak ShowGroupMembersViewController * weakSelf = self ;
UIAlertAction * verifyAction = [ UIAlertAction
actionWithTitle : NSLocalizedString ( @ "OK ", nil )
style : UIAlertActionStyleDestructive
handler : ^( UIAlertAction * _Nonnull action ) {
[ weakSelf resetAllNoLongerVerified ] ;
} ] ;
[ actionSheetController addAction : verifyAction ] ;
UIAlertAction * cancelAction = [ UIAlertAction actionWithTitle : NSLocalizedString ( @ "TXT_CANCEL_TITLE ", @ "")
style : UIAlertActionStyleCancel
handler : nil ] ;
[ actionSheetController addAction : cancelAction ] ;
[ self presentViewController : actionSheetController animated : YES completion : nil ] ;
}
- ( void ) resetAllNoLongerVerified
{
OWSAssert ( [ NSThread isMainThread ] ) ;
OWSIdentityManager * identityManger = [ OWSIdentityManager sharedManager ] ;
NSArray < NSString * > * recipientIds = [ self noLongerVerifiedRecipientIds ] ;
for ( NSString * recipientId in recipientIds ) {
OWSVerificationState verificationState = [ identityManger verificationStateForRecipientId : recipientId ] ;
if ( verificationState == OWSVerificationStateNoLongerVerified ) {
NSData * identityKey = [ identityManger identityKeyForRecipientId : recipientId ] ;
if ( identityKey . length < 1 ) {
OWSFail ( @ "Missing identity key for : %@", recipientId);
continue ;
}
[ identityManger setVerificationState : OWSVerificationStateDefault
identityKey : identityKey
recipientId : recipientId
isUserInitiatedChange : YES ] ;
}
}
[ self updateTableContents ] ;
}
/ / Returns a collection of the group members who are "no longer verified ".
- ( NSArray < NSString * > * ) noLongerVerifiedRecipientIds
{
NSMutableArray < NSString * > * result = [ NSMutableArray new ] ;
for ( NSString * recipientId in self . thread . recipientIdentifiers ) {
if ( [ [ OWSIdentityManager sharedManager ] verificationStateForRecipientId : recipientId ]
== OWSVerificationStateNoLongerVerified ) {
[ result addObject : recipientId ] ;
}
}
return [ result copy ] ;
}
}
- ( void ) didSelectRecipientId : ( NSString * ) recipientId
- ( void ) didSelectRecipientId : ( NSString * ) recipientId
@ -280,7 +386,7 @@ NS_ASSUME_NONNULL_BEGIN
@ "safety number of another user . ")
@ "safety number of another user . ")
style : UIAlertActionStyleDefault
style : UIAlertActionStyleDefault
handler : ^( UIAlertAction * _Nonnull action ) {
handler : ^( UIAlertAction * _Nonnull action ) {
[ self verifySafetyNumber : recipientId ] ;
[ self showSafetyNumberView : recipientId ] ;
} ] ] ;
} ] ] ;
}
}
@ -313,7 +419,7 @@ NS_ASSUME_NONNULL_BEGIN
[ Environment callUserWithIdentifier : recipientId ] ;
[ Environment callUserWithIdentifier : recipientId ] ;
}
}
- ( void ) verifySafetyNumber : ( NSString * ) recipientId
- ( void ) showSafetyNumberView : ( NSString * ) recipientId
{
{
OWSAssert ( recipientId . length > 0 ) ;
OWSAssert ( recipientId . length > 0 ) ;