1
0
mirror of https://github.com/danog/Telegram.git synced 2025-01-22 14:02:24 +01:00
Telegram/Watch/Bridge/TGBridgeActionMediaAttachment+TGActionMediaAttachment.m
2015-10-01 19:19:52 +03:00

35 lines
1.2 KiB
Objective-C

#import "TGBridgeActionMediaAttachment+TGActionMediaAttachment.h"
#import "TGBridgeImageMediaAttachment+TGImageMediaAttachment.h"
@implementation TGBridgeActionMediaAttachment (TGActionMediaAttachment)
+ (TGBridgeActionMediaAttachment *)attachmentWithTGActionMediaAttachment:(TGActionMediaAttachment *)attachment
{
if (attachment == nil)
return nil;
TGBridgeActionMediaAttachment *bridgeAttachment = [[TGBridgeActionMediaAttachment alloc] init];
bridgeAttachment.actionType = (TGBridgeMessageAction)attachment.actionType;
NSMutableDictionary *actionData = [[NSMutableDictionary alloc] init];
for (id key in attachment.actionData.allKeys)
{
id value = attachment.actionData[key];
if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
{
actionData[key] = value;
}
else if ([value isKindOfClass:[TGImageMediaAttachment class]])
{
actionData[key] = [TGBridgeImageMediaAttachment attachmentWithTGImageMediaAttachment:(TGImageMediaAttachment *)value];
}
}
bridgeAttachment.actionData = actionData;
return bridgeAttachment;
}
@end