Add recording type to notifications

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Marcel Müller 2023-02-23 23:27:26 +01:00
Родитель 16ad760d54
Коммит bae926cea4
4 изменённых файлов: 37 добавлений и 5 удалений

Просмотреть файл

@ -25,7 +25,8 @@
typedef enum NCNotificationType {
kNCNotificationTypeRoom = 0,
kNCNotificationTypeChat,
kNCNotificationTypeCall
kNCNotificationTypeCall,
kNCNotificationTypeRecording
} NCNotificationType;
@interface NCNotification : NSObject
@ -40,6 +41,8 @@ typedef enum NCNotificationType {
@property (nonatomic, strong) NSString *message;
@property (nonatomic, strong) NSString *messageRich;
@property (nonatomic, strong) NSDictionary *messageRichParameters;
@property (nonatomic, strong) NSArray *actions;
@property (nonatomic, strong) NSDate *datetime;
+ (instancetype)notificationWithDictionary:(NSDictionary *)notificationDict;
- (NCNotificationType)notificationType;
@ -47,5 +50,6 @@ typedef enum NCNotificationType {
- (NSString *)chatMessageTitle;
- (NSString *)callDisplayName;
- (NSString *)roomToken;
- (NSArray *)notificationActions;
@end

Просмотреть файл

@ -22,6 +22,8 @@
#import "NCNotification.h"
#import "NextcloudTalk-Swift.h"
@implementation NCNotification
+ (instancetype)notificationWithDictionary:(NSDictionary *)notificationDict
@ -41,7 +43,11 @@
notification.message = [notificationDict objectForKey:@"message"];
notification.messageRich = [notificationDict objectForKey:@"messageRich"];
notification.messageRichParameters = [notificationDict objectForKey:@"messageRichParameters"];
notification.actions = [notificationDict objectForKey:@"actions"];
NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init];
notification.datetime = [formatter dateFromString:[notificationDict objectForKey:@"datetime"]];
if (![notification.subjectRichParameters isKindOfClass:[NSDictionary class]]) {
notification.subjectRichParameters = @{};
}
@ -58,6 +64,8 @@
NCNotificationType type = kNCNotificationTypeRoom;
if ([_objectType isEqualToString:@"chat"]) {
type = kNCNotificationTypeChat;
} else if ([_objectType isEqualToString:@"recording"]) {
type = kNCNotificationTypeRecording;
} else if ([_objectType isEqualToString:@"call"]) {
type = kNCNotificationTypeCall;
}
@ -126,4 +134,21 @@
return [parameterRegex matchesInString:text options:0 range:NSMakeRange(0, [text length])];
}
- (NSArray *)notificationActions
{
if (!self.actions) {
return nil;
}
NSMutableArray *resultActions = [[NSMutableArray alloc] init];
for (NSDictionary *dict in self.actions) {
NCNotificationAction *notificationAction = [[NCNotificationAction alloc] initWithDictionary:dict];
[resultActions addObject:notificationAction];
}
return resultActions;
}
@end

Просмотреть файл

@ -30,7 +30,8 @@ typedef NS_ENUM(NSInteger, NCPushNotificationType) {
NCPushNotificationTypeDelete,
NCPushNotificationTypeDeleteAll,
NCPushNotificationTypeDeleteMultiple,
NCPushNotificationTypeAdminNotification
NCPushNotificationTypeAdminNotification,
NCPushNotificationTypeRecording
};
extern NSString * const kNCPNAppKey;
@ -42,6 +43,7 @@ extern NSString * const kNCPNNotifIdKey;
extern NSString * const kNCPNTypeCallKey;
extern NSString * const kNCPNTypeRoomKey;
extern NSString * const kNCPNTypeChatKey;
extern NSString * const kNCPNTypeRecording;
extern NSString * const NCPushNotificationJoinChatNotification;
extern NSString * const NCPushNotificationJoinAudioCallAcceptedNotification;
@ -53,7 +55,6 @@ extern NSString * const NCPushNotificationJoinVideoCallAcceptedNotification;
@property (nonatomic, assign) NCPushNotificationType type;
@property (nonatomic, copy) NSString *subject;
@property (nonatomic, copy) NSString *roomToken;
@property (nonatomic, assign) NSInteger roomId;
@property (nonatomic, assign) NSInteger notificationId;
@property (nonatomic, strong) NSArray *notificationIds;
@property (nonatomic, copy) NSString *accountId;

Просмотреть файл

@ -37,6 +37,7 @@ NSString * const kNCPNTypeChatKey = @"chat";
NSString * const kNCPNTypeDeleteKey = @"delete";
NSString * const kNCPNTypeDeleteAllKey = @"delete-all";
NSString * const kNCPNTypeDeleteMultipleKey = @"delete-multiple";
NSString * const kNCPNTypeRecording = @"recording";
NSString * const kNCPNAppIdAdminNotificationKey = @"admin_notification_talk";
NSString * const NCPushNotificationJoinChatNotification = @"NCPushNotificationJoinChatNotification";
@ -62,7 +63,6 @@ NSString * const NCPushNotificationJoinVideoCallAcceptedNotification = @"NCPu
pushNotification.app = app;
pushNotification.subject = [jsonDict objectForKey:kNCPNSubjectKey];
pushNotification.roomToken = [jsonDict objectForKey:kNCPNIdKey];
pushNotification.roomId = [[jsonDict objectForKey:kNCPNIdKey] integerValue];
pushNotification.notificationId = [[jsonDict objectForKey:kNCPNNotifIdKey] integerValue];
NSString *type = [jsonDict objectForKey:kNCPNTypeKey];
@ -73,6 +73,8 @@ NSString * const NCPushNotificationJoinVideoCallAcceptedNotification = @"NCPu
pushNotification.type = NCPushNotificationTypeRoom;
} else if ([type isEqualToString:kNCPNTypeChatKey]) {
pushNotification.type = NCPushNotificationTypeChat;
} else if ([type isEqualToString:kNCPNTypeRecording]) {
pushNotification.type = NCPushNotificationTypeRecording;
}
pushNotification.accountId = accountId;