#nullable enable using Bit.Core.Enums; namespace Bit.Core.Platform.Push; /// /// Contains constants for all the available targets for a given notification. /// /// /// Please reach out to the Platform team if you need a new target added. /// public enum NotificationTarget { /// /// The target for the notification is a single user. /// User, /// /// The target for the notification are all the users in an organization. /// Organization, /// /// The target for the notification are all the organizations, /// and all the users in that organization for a installation. /// Installation, } /// /// An object containing all the information required for getting a notification /// to an end users device and the information you want available to that device. /// /// The type of the payload. This type is expected to be able to be roundtripped as JSON. public record PushNotification where T : class { /// /// The to be associated with the notification. This is used to route /// the notification to the correct handler on the client side. Be sure to use the correct payload /// type for the associated . /// public required PushType Type { get; init; } /// /// The target entity type for the notification. /// /// /// When the target type is the /// property is expected to be a users ID. When it is /// it should be an organizations id. When it is a /// it should be an installation id. /// public required NotificationTarget Target { get; init; } /// /// The indentifier for the given . /// public required Guid TargetId { get; init; } /// /// The payload to be sent with the notification. This object will be JSON serialized. /// public required T Payload { get; init; } /// /// When the notification will not include the current context identifier on it, this /// means that the notification may get handled on the device that this notification could have originated from. /// public required bool ExcludeCurrentContext { get; init; } /// /// The type of clients the notification should be sent to, if then /// is inferred. /// public ClientType? ClientType { get; init; } internal Guid? GetTargetWhen(NotificationTarget notificationTarget) { return Target == notificationTarget ? TargetId : null; } }