Adds conversation delete option
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMDeleteConversationOperation.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 5/25/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMDeleteConversationOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// MBIMDeleteConversationOperation.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 5/25/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMDeleteConversationOperation.h"
|
||||
#import "IMChat+Encoded.h"
|
||||
|
||||
#import "IMCore_ClassDump.h"
|
||||
|
||||
@implementation MBIMDeleteConversationOperation
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"delete";
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
__block NSObject<HTTPResponse> *response = nil;
|
||||
do {
|
||||
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
||||
|
||||
if (!guid) {
|
||||
MBIMLogInfo(@"No conversation GUID provided.");
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
break;
|
||||
}
|
||||
|
||||
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
||||
IMChat *chat = [[IMChatRegistry sharedInstance] existingChatWithGUID:guid];
|
||||
if (!chat) {
|
||||
MBIMLogInfo(@"Chat with guid: %@ not found", guid);
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
} else {
|
||||
[chat remove];
|
||||
}
|
||||
});
|
||||
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:200];
|
||||
} while (0);
|
||||
|
||||
self.serverCompletionBlock(response);
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user