-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for MatrixRTC m.call.notify events.
- Loading branch information
Showing
8 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Copyright 2024 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MXJSONModel.h" | ||
#import "MXMentions.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
`MXCallNotify` represents a push notification for a MatrixRTC call, | ||
describing how the user should be notified about the call. | ||
*/ | ||
@interface MXCallNotify : MXJSONModel | ||
|
||
/** | ||
The application that is running the MatrixRTC session. `m.call` represents a VoIP call. | ||
*/ | ||
@property (nonatomic) NSString *application; | ||
|
||
/** | ||
Information about who should be notified in the room. | ||
*/ | ||
@property (nonatomic) MXMentions *mentions; | ||
|
||
/** | ||
Whether the call should ring or deliver a notification. | ||
*/ | ||
@property (nonatomic) NSString *notifyType; | ||
|
||
/** | ||
A unique identifier for the call that is running. Present for an application type of `m.call`. | ||
*/ | ||
@property (nonatomic, nullable) NSString *callID; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright 2024 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "MXCallNotify.h" | ||
#import "MXMentions.h" | ||
|
||
@implementation MXCallNotify | ||
|
||
+ (id)modelFromJSON:(NSDictionary *)JSONDictionary | ||
{ | ||
MXCallNotify *callNotify = [[MXCallNotify alloc] init]; | ||
if (callNotify) | ||
{ | ||
MXJSONModelSetString(callNotify.application, JSONDictionary[@"application"]); | ||
MXJSONModelSetMXJSONModel(callNotify.mentions, MXMentions, JSONDictionary[@"m.mentions"]); | ||
MXJSONModelSetString(callNotify.notifyType, JSONDictionary[@"notify_type"]); | ||
MXJSONModelSetString(callNotify.callID, JSONDictionary[@"call_id"]); | ||
} | ||
|
||
return callNotify; | ||
} | ||
|
||
- (NSDictionary *)JSONDictionary | ||
{ | ||
NSMutableDictionary *JSONDictionary = [NSMutableDictionary dictionary]; | ||
|
||
JSONDictionary[@"application"] = _application; | ||
JSONDictionary[@"m.mentions"] = _mentions.JSONDictionary; | ||
JSONDictionary[@"notify_type"] = _notifyType; | ||
JSONDictionary[@"call_id"] = _callID; | ||
|
||
return JSONDictionary; | ||
} | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Copyright 2024 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import <MatrixSDK/MatrixSDK.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
Describes whether an event mentions other users or the room | ||
*/ | ||
@interface MXMentions : MXJSONModel | ||
|
||
/** | ||
The user IDs of room members who should be notified about this event. | ||
*/ | ||
@property (nonatomic, nullable) NSArray *userIDs; | ||
|
||
/** | ||
Whether or not this event contains an @room mention. | ||
*/ | ||
@property (nonatomic) BOOL room; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Copyright 2024 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "MXMentions.h" | ||
|
||
@implementation MXMentions | ||
|
||
+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary | ||
{ | ||
MXMentions *intentionalMentions = [[MXMentions alloc] init]; | ||
if (intentionalMentions) | ||
{ | ||
MXJSONModelSetString(intentionalMentions.userIDs, JSONDictionary[@"user_ids"]); | ||
MXJSONModelSetBoolean(intentionalMentions.room, JSONDictionary[@"room"]); | ||
} | ||
|
||
return intentionalMentions; | ||
} | ||
|
||
- (NSDictionary *)JSONDictionary | ||
{ | ||
NSMutableDictionary *JSONDictionary = [NSMutableDictionary dictionary]; | ||
|
||
JSONDictionary[@"user_ids"] = _userIDs; | ||
JSONDictionary[@"room"] = @(_room); | ||
|
||
return JSONDictionary; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters