From ebad248c1c0896af50c3493753a150dac4e66f2d Mon Sep 17 00:00:00 2001 From: James Magahern Date: Wed, 25 May 2022 22:34:19 -0700 Subject: [PATCH] Adds conversation delete option --- MessagesBridge.xcodeproj/project.pbxproj | 6 +++ .../MBIMDeleteConversationOperation.h | 17 +++++++ .../MBIMDeleteConversationOperation.m | 49 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 kordophone/Bridge/Operations/MBIMDeleteConversationOperation.h create mode 100644 kordophone/Bridge/Operations/MBIMDeleteConversationOperation.m diff --git a/MessagesBridge.xcodeproj/project.pbxproj b/MessagesBridge.xcodeproj/project.pbxproj index af6d7d7..0655252 100644 --- a/MessagesBridge.xcodeproj/project.pbxproj +++ b/MessagesBridge.xcodeproj/project.pbxproj @@ -81,6 +81,7 @@ CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602061219B68950024D9C5 /* MBIMSendMessageOperation.m */; }; CD83E156219BE10A00F4CCEA /* hooking.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E155219BE10A00F4CCEA /* hooking.m */; }; CD83E166219BE91600F4CCEA /* agentHook.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E165219BE91600F4CCEA /* agentHook.m */; }; + CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */; }; CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */; }; CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */; }; CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */; }; @@ -236,6 +237,8 @@ CD83E161219BE91500F4CCEA /* libagentHook.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libagentHook.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; CD83E165219BE91600F4CCEA /* agentHook.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = agentHook.m; sourceTree = ""; }; CD83E1B5219BF78E00F4CCEA /* hookAgent.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = hookAgent.sh; sourceTree = ""; }; + CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMDeleteConversationOperation.h; sourceTree = ""; }; + CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMDeleteConversationOperation.m; sourceTree = ""; }; CDE4556221A3578A0041F5DD /* IMChat+Encoded.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IMChat+Encoded.h"; sourceTree = ""; }; CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "IMChat+Encoded.m"; sourceTree = ""; }; CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMarkOperation.h; sourceTree = ""; }; @@ -526,6 +529,8 @@ CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */, CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */, CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */, + CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */, + CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */, CDE455A221A5308D0041F5DD /* MBIMFetchAttachmentOperation.h */, CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */, CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */, @@ -836,6 +841,7 @@ CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */, CD83E156219BE10A00F4CCEA /* hooking.m in Sources */, 1AAB32B121F82EB7004A2A72 /* MBIMLogging.m in Sources */, + CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */, 1AD8936E21EFD986009B599A /* MBIMUploadAttachmentOperation.m in Sources */, CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */, CDF62335219A895D00690038 /* main.m in Sources */, diff --git a/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.h b/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.h new file mode 100644 index 0000000..df3996f --- /dev/null +++ b/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.h @@ -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 diff --git a/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.m b/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.m new file mode 100644 index 0000000..2db40cc --- /dev/null +++ b/kordophone/Bridge/Operations/MBIMDeleteConversationOperation.m @@ -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 *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