mirror of
https://github.com/danog/Telegram.git
synced 2024-12-02 17:38:07 +01:00
53 lines
1.6 KiB
Mathematica
53 lines
1.6 KiB
Mathematica
|
#import "TGConversationDeleteActor.h"
|
||
|
|
||
|
#import "ActionStage.h"
|
||
|
|
||
|
#import "TGTelegraph.h"
|
||
|
#import "TGDatabase.h"
|
||
|
|
||
|
#import "TGUpdateStateRequestBuilder.h"
|
||
|
|
||
|
#import "TGDownloadManager.h"
|
||
|
|
||
|
@implementation TGConversationDeleteActor
|
||
|
|
||
|
+ (NSString *)genericPath
|
||
|
{
|
||
|
return @"/tg/conversation/@/delete";
|
||
|
}
|
||
|
|
||
|
- (void)execute:(NSDictionary *)options
|
||
|
{
|
||
|
int64_t conversationId = [[options objectForKey:@"conversationId"] longLongValue];
|
||
|
if (conversationId == 0)
|
||
|
{
|
||
|
[ActionStageInstance() actionFailed:self.path reason:-1];
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
[[TGDownloadManager instance] cancelItemsWithGroupId:conversationId];
|
||
|
|
||
|
[TGDatabaseInstance() deleteConversation:conversationId populateActionQueue:true];
|
||
|
|
||
|
dispatch_async([ActionStageInstance() globalStageDispatchQueue], ^
|
||
|
{
|
||
|
[ActionStageInstance() requestActor:@"/tg/service/synchronizeactionqueue/(global)" options:nil watcher:TGTelegraphInstance];
|
||
|
|
||
|
NSArray *sendMessageActors = [ActionStageInstance() executingActorsWithPathPrefix:[NSString stringWithFormat:@"/tg/sendCommonMessage/(%lld)/", conversationId]];
|
||
|
for (TGActor *actor in sendMessageActors)
|
||
|
{
|
||
|
[ActionStageInstance() removeAllWatchersFromPath:actor.path];
|
||
|
}
|
||
|
|
||
|
sendMessageActors = [ActionStageInstance() executingActorsWithPathPrefix:[NSString stringWithFormat:@"/tg/sendSecretMessage/(%lld)/", conversationId]];
|
||
|
for (TGActor *actor in sendMessageActors)
|
||
|
{
|
||
|
[ActionStageInstance() removeAllWatchersFromPath:actor.path];
|
||
|
}
|
||
|
});
|
||
|
|
||
|
[ActionStageInstance() actionCompleted:self.path result:nil];
|
||
|
}
|
||
|
|
||
|
@end
|