Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip api notif: more comments; TODO incomplete graf
Browse files Browse the repository at this point in the history
gnprice committed Oct 18, 2023
1 parent 27fb97c commit e5fa015
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/api/notifications.dart
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@ part 'notifications.g.dart';

/// Parsed version of an FCM message, of any type.
///
/// Firebase Cloud Messaging (FCM) is the service run by Google that we use
/// for delivering notifications to Android devices.
/// TODO write more here
///
/// The word "message" can be confusing in this context:
///
/// * FCM docs say "message" to refer to one of the blobs we receive over FCM,
@@ -30,6 +34,7 @@ sealed class FcmMessage {
Map<String, dynamic> toJson();
}

/// An [FcmMessage] of a type (a value of `event`) we didn't know about.
class UnexpectedFcmMessage extends FcmMessage {
final Map<String, dynamic> json;

@@ -39,10 +44,31 @@ class UnexpectedFcmMessage extends FcmMessage {
Map<String, dynamic> toJson() => json;
}

/// Base class for [FcmMessage]s that identify what Zulip account they're for.
///
/// This includes all known types of FCM messages from Zulip
/// (all [FcmMessage] subclasses other than [UnexpectedFcmMessage]),
/// and it seems likely that it always will.
sealed class FcmMessageWithIdentity extends FcmMessage {
/// The server's `EXTERNAL_HOST` setting. This is a hostname,
/// or a colon-separated hostname-plus-port.
///
/// For documentation, see zulip-server:zproject/prod_settings_template.py .
final String server;

/// The realm's ID within the server.
final int realmId;

/// The realm's own URL.
///
/// This is a real, absolute URL which is the base for all URLs a client uses
/// with this realm. It corresponds to [GetServerSettingsResult.realmUri].
final Uri realmUri;

/// This user's ID within the server.
///
/// Useful mainly in the case where the user has multiple accounts in the
/// same realm.
final int userId;

FcmMessageWithIdentity({

0 comments on commit e5fa015

Please sign in to comment.