-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notifications_push_repository): Init
Signed-off-by: provokateurin <[email protected]>
- Loading branch information
1 parent
dee4005
commit 7ec5abb
Showing
23 changed files
with
2,739 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
1 change: 1 addition & 0 deletions
1
packages/neon_framework/packages/notifications_push_repository/LICENSE
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 @@ | ||
../../../../assets/AGPL-3.0.txt |
5 changes: 5 additions & 0 deletions
5
packages/neon_framework/packages/notifications_push_repository/analysis_options.yaml
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,5 @@ | ||
include: package:neon_lints/dart.yaml | ||
|
||
custom_lint: | ||
rules: | ||
- avoid_exports: false |
4 changes: 4 additions & 0 deletions
4
...n_framework/packages/notifications_push_repository/lib/notifications_push_repository.dart
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,4 @@ | ||
export 'src/models/models.dart' show PushNotification; | ||
export 'src/notifications_push_repository.dart'; | ||
export 'src/notifications_push_storage.dart'; | ||
export 'src/utils/encryption.dart' show parseEncryptedPushNotifications; |
2 changes: 2 additions & 0 deletions
2
packages/neon_framework/packages/notifications_push_repository/lib/src/models/models.dart
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,2 @@ | ||
export 'push_notification.dart'; | ||
export 'push_subscription.dart'; |
63 changes: 63 additions & 0 deletions
63
...on_framework/packages/notifications_push_repository/lib/src/models/push_notification.dart
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,63 @@ | ||
import 'package:built_value/built_value.dart'; | ||
import 'package:built_value/serializer.dart'; | ||
import 'package:built_value/standard_json_plugin.dart'; | ||
import 'package:crypton/crypton.dart'; | ||
import 'package:nextcloud/notifications.dart' as notifications; | ||
|
||
part 'push_notification.g.dart'; | ||
|
||
/// Data for a push notification. | ||
abstract class PushNotification implements Built<PushNotification, PushNotificationBuilder> { | ||
/// Creates a new [PushNotification]. | ||
factory PushNotification([void Function(PushNotificationBuilder)? updates]) = _$PushNotification; | ||
|
||
const PushNotification._(); | ||
|
||
/// Creates a new PushNotification object from the given [json] data containing an encrypted [subject]. | ||
/// | ||
/// Use [PushNotification.fromJson] when the [subject] is not encrypted. | ||
factory PushNotification.fromEncrypted( | ||
Map<String, dynamic> json, | ||
String accountID, | ||
RSAPrivateKey privateKey, | ||
) { | ||
final subject = notifications.DecryptedSubject.fromEncrypted(privateKey, json['subject'] as String); | ||
|
||
return PushNotification( | ||
(b) => b | ||
..accountID = accountID | ||
..priority = json['priority'] as String | ||
..type = json['type'] as String | ||
..subject.replace(subject), | ||
); | ||
} | ||
|
||
/// Creates a new PushNotification object from the given [json] data. | ||
/// | ||
/// Use [PushNotification.fromEncrypted] when you the [subject] is still encrypted. | ||
factory PushNotification.fromJson(Map<String, dynamic> json) => _serializers.deserializeWith(serializer, json)!; | ||
|
||
/// Parses this object into a json like map. | ||
Map<String, dynamic> toJson() => _serializers.serializeWith(serializer, this)! as Map<String, dynamic>; | ||
|
||
/// The serializer for [PushNotification]. | ||
static Serializer<PushNotification> get serializer => _$pushNotificationSerializer; | ||
|
||
/// The account associated with this notification. | ||
String get accountID; | ||
|
||
/// The priority of the notification. | ||
String get priority; | ||
|
||
/// The type of the notification. | ||
String get type; | ||
|
||
/// The subject of this notification. | ||
notifications.DecryptedSubject get subject; | ||
} | ||
|
||
final Serializers _serializers = (Serializers().toBuilder() | ||
..add(notifications.DecryptedSubject.serializer) | ||
..add(PushNotification.serializer) | ||
..addPlugin(StandardJsonPlugin())) | ||
.build(); |
195 changes: 195 additions & 0 deletions
195
..._framework/packages/notifications_push_repository/lib/src/models/push_notification.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...on_framework/packages/notifications_push_repository/lib/src/models/push_subscription.dart
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,30 @@ | ||
import 'package:built_value/built_value.dart'; | ||
import 'package:built_value/serializer.dart'; | ||
import 'package:built_value/standard_json_plugin.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:nextcloud/notifications.dart' as notifications; | ||
|
||
part 'push_subscription.g.dart'; | ||
|
||
@internal | ||
abstract class PushSubscription implements Built<PushSubscription, PushSubscriptionBuilder> { | ||
factory PushSubscription([void Function(PushSubscriptionBuilder)? updates]) = _$PushSubscription; | ||
|
||
const PushSubscription._(); | ||
|
||
factory PushSubscription.fromJson(Map<String, dynamic> json) => _serializers.deserializeWith(serializer, json)!; | ||
|
||
Map<String, dynamic> toJson() => _serializers.serializeWith(serializer, this)! as Map<String, dynamic>; | ||
|
||
static Serializer<PushSubscription> get serializer => _$pushSubscriptionSerializer; | ||
|
||
String? get endpoint; | ||
|
||
notifications.PushDevice? get pushDevice; | ||
} | ||
|
||
final Serializers _serializers = (Serializers().toBuilder() | ||
..add(notifications.PushDevice.serializer) | ||
..add(PushSubscription.serializer) | ||
..addPlugin(StandardJsonPlugin())) | ||
.build(); |
Oops, something went wrong.