Skip to content

Commit c8f504b

Browse files
Add new action to block subscription requests, fixes #1320
1 parent c8e488f commit c8f504b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Monal/Classes/ContactRequestsMenu.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ struct ContactRequestsMenuEntry: View {
2828
//see https://www.hackingwithswift.com/forums/swiftui/tap-button-in-hstack-activates-all-button-actions-ios-14-swiftui-2/2952
2929
.buttonStyle(BorderlessButtonStyle())
3030

31+
Button {
32+
// deny request
33+
MLXMPPManager.sharedInstance().remove(contact)
34+
MLXMPPManager.sharedInstance().block(true, contact:contact)
35+
} label: {
36+
Image(systemName: "xmark.circle")
37+
.foregroundStyle(Color.red)
38+
}
39+
//see https://www.hackingwithswift.com/forums/swiftui/tap-button-in-hstack-activates-all-button-actions-ios-14-swiftui-2/2952
40+
.buttonStyle(BorderlessButtonStyle())
41+
3142
Button {
3243
// deny request
3344
MLXMPPManager.sharedInstance().remove(contact)

Monal/Classes/MonalAppDelegate.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ -(BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(
452452
actionWithIdentifier:@"DENY_SUBSCRIPTION_ACTION"
453453
title:NSLocalizedString(@"Deny new contact", @"")
454454
options:UNNotificationActionOptionNone
455+
icon:[UNNotificationActionIcon iconWithSystemImageName:@"person.crop.circle.badge.minus"]
456+
];
457+
UNNotificationAction* blockSubscriptionAction = [UNNotificationAction
458+
actionWithIdentifier:@"BLOCK_SUBSCRIPTION_ACTION"
459+
title:NSLocalizedString(@"Block new contact", @"")
460+
options:UNNotificationActionOptionNone
455461
icon:[UNNotificationActionIcon iconWithSystemImageName:@"person.crop.circle.badge.xmark"]
456462
];
457463

@@ -467,7 +473,7 @@ -(BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(
467473
];
468474
UNNotificationCategory* subscriptionCategory = [UNNotificationCategory
469475
categoryWithIdentifier:@"subscription"
470-
actions:@[approveSubscriptionAction, denySubscriptionAction]
476+
actions:@[approveSubscriptionAction, denySubscriptionAction, blockSubscriptionAction]
471477
intentIdentifiers:@[]
472478
options:UNNotificationCategoryOptionCustomDismissAction
473479
];
@@ -998,6 +1004,12 @@ -(void) userNotificationCenter:(UNUserNotificationCenter*) center didReceiveNoti
9981004
DDLogInfo(@"DENY_SUBSCRIPTION_ACTION triggered...");
9991005
[[MLXMPPManager sharedInstance] removeContact:fromContact];
10001006
}
1007+
else if([response.actionIdentifier isEqualToString:@"BLOCK_SUBSCRIPTION_ACTION"])
1008+
{
1009+
DDLogInfo(@"BLOCK_SUBSCRIPTION_ACTION triggered...");
1010+
[[MLXMPPManager sharedInstance] removeContact:fromContact];
1011+
[[MLXMPPManager sharedInstance] block:YES contact:fromContact];
1012+
}
10011013
else if([response.actionIdentifier isEqualToString:@"com.apple.UNNotificationDefaultActionIdentifier"]) //open chat of this contact
10021014
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
10031015
while(self.activeChats == nil)

0 commit comments

Comments
 (0)