Private
Public Access
1
0

Adds conversation delete option

This commit is contained in:
2022-05-25 22:34:19 -07:00
parent e161eedef3
commit ebad248c1c
3 changed files with 72 additions and 0 deletions

View File

@@ -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

View File

@@ -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