/** * Notifications and Mobile pushes * * Notifications are types used for the in-app notification feed * * Mobile pushes are payloads delivered to mobile apps */ import { ClientsCoachData, Program } from '.'; import { HevyChatUpdateMobilePushData } from './chat'; export type Notification = WorkoutCompleteNotification | WorkoutMentionNotification | WorkoutCommentNotification | WorkoutCommentMentionNotification | WorkoutCommentReplyNotification | WorkoutCommentDiscussionNotification | WorkoutLikeNotification | WorkoutCommentLikeNotification | FollowNotification | FollowRequestNotification | AcceptFollowRequestNotification | CoachClientInviteNotification | ContactOnHevyNotification; export type NotificationType = 'workout-complete' | 'workout-mention' | 'workout-comment' | 'workout-comment-mention' | 'workout-comment-reply' | 'workout-comment-reply-v2' | 'workout-like' | 'workout-comment-like' | 'follow' | 'follow-request' | 'accept-follow-request' | 'coach-client-invite' | 'contact-on-hevy'; export interface BaseNotification { id: number; type: NotificationType; from_username: string; profile_pic?: string; date: string; } export interface BaseMobilePushData { type: MobilePushDataType; deeplink?: string; profilePic?: string; cue_notification_group_identifier?: string; additionalHevyData?: any; } export interface WorkoutCompleteNotification extends BaseNotification { type: 'workout-complete'; workout_id: string; workout_title: string; } export interface WorkoutCompleteMobilePushData extends BaseMobilePushData { type: 'workout-complete'; } export interface WorkoutMentionNotification extends BaseNotification { type: 'workout-mention'; workout_id: string; workout_title: string; } export interface WorkoutMentionMobilePushData extends BaseMobilePushData { type: 'workout-mention'; } export interface WorkoutCommentNotification extends BaseNotification { type: 'workout-comment'; workout_id: string; workout_title: string; comment: string; } export interface WorkoutCommentMobilePushData extends BaseMobilePushData { type: 'workout-comment'; } export interface WorkoutCommentDiscussionNotification extends BaseNotification { type: 'workout-comment-reply'; workout_id: string; workout_title: string; comment: string; } export interface WorkoutCommentDiscussionMobilePushData extends BaseMobilePushData { type: 'workout-comment-reply'; } export interface WorkoutCommentMentionNotification extends BaseNotification { type: 'workout-comment-mention'; workout_id: string; workout_title: string; comment: string; } export interface WorkoutCommentMentionMobilePushData extends BaseMobilePushData { type: 'workout-comment-mention'; } export interface WorkoutCommentReplyNotification extends BaseNotification { type: 'workout-comment-reply-v2'; workout_id: string; workout_title: string; comment: string; } export interface WorkoutCommentReplyMobilePushData extends BaseMobilePushData { type: 'workout-comment-reply-v2'; } export interface WorkoutLikeNotification extends BaseNotification { type: 'workout-like'; workout_id: string; workout_title: string; } export interface WorkoutLikeMobilePushData extends BaseMobilePushData { type: 'workout-like'; } export interface WorkoutCommentLikeNotification extends BaseNotification { type: 'workout-comment-like'; workout_id: string; workout_title: string; comment_id: number; comment: string; } export interface WorkoutCommentLikeMobilePushData extends BaseMobilePushData { type: 'workout-comment-like'; } export interface FollowNotification extends BaseNotification { type: 'follow'; } export interface FollowMobilePushData extends BaseMobilePushData { type: 'follow'; } export interface FollowRequestNotification extends BaseNotification { type: 'follow-request'; } export interface FollowRequestMobilePushData extends BaseMobilePushData { type: 'follow-request'; } export interface AcceptFollowRequestNotification extends BaseNotification { type: 'accept-follow-request'; } export interface AcceptFollowRequestMobilePushData extends BaseMobilePushData { type: 'accept-follow-request'; } export interface CoachClientInviteNotification extends BaseNotification { type: 'coach-client-invite'; from_full_name?: string; } export interface CoachClientInviteMobilePushData extends BaseMobilePushData { type: 'coach-client-invite'; } export interface ContactOnHevyNotification extends BaseNotification { type: 'contact-on-hevy'; contact_name: string; } export interface ContactOnHevyMobilePushData extends BaseMobilePushData { type: 'contact-on-hevy'; } /** * "Pushes": a push is basically a remote notification, NOT to be confused with a "notification", which is * a data type in the Hevy database */ export type MobilePushDataType = NotificationMobilePushDataType | DataOnlyMobilePushDataType; /** * These types will have an alert/title, and will only be delivered if the user has given the notification * permission to the App */ export type NotificationMobilePushDataType = NotificationType | 'chat-update' | 'coach-program-finishes-next-week' | 'coach-program-starts-today' | 'coach-logged-your-workout' | 'coach-logged-your-measurements' | 'monthly-report' | 'grace-period-enter' | 'grace-period-resolve'; /** * These types CAN NOT have an alert/title, but may be delivered even if the user has not given the notification * permission and even if Hevy isn't running, although these should be treated as best effort * For iOS/Apple see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app * For Android see https://firebase.google.com/docs/cloud-messaging/concept-options#data_messages */ export type DataOnlyMobilePushDataType = 'coach-data-changed' | 'coach-program-changed' | 'sync-workouts' | 'sync-routines' | 'sync-routine-folders' | 'sync-exercise-templates-and-customizations' | 'sync-account' | 'hevy-pro-status-changed' | 'hevy-pro-subscription-renewed' | 'new-notification' | 'live-workout-update' | 'live-workout-delete' | 'live-workout-comment-received' | never; export interface CoachDataChangedMobilePushData extends BaseMobilePushData { type: 'coach-data-changed'; additionalHevyData: ClientsCoachData; } export interface CoachProgramChangedMobilePushData extends BaseMobilePushData { type: 'coach-program-changed'; additionalHevyData: { program: Program | undefined; }; } export interface HevyProSubscriptionRenewedMobilePushData extends BaseMobilePushData { type: 'hevy-pro-subscription-renewed'; } export interface ProStatusChangedPushMobilePushData extends BaseMobilePushData { type: 'hevy-pro-status-changed'; } export interface SyncWorkoutsMobilePushData extends BaseMobilePushData { type: 'sync-workouts'; } export interface SyncRoutinesMobilePushData extends BaseMobilePushData { type: 'sync-routines'; } export interface SyncRoutineFoldersMobilePushData extends BaseMobilePushData { type: 'sync-routine-folders'; } export interface SyncCustomExercisesAndCoachCustomizationsMobilePushData extends BaseMobilePushData { type: 'sync-exercise-templates-and-customizations'; } export interface SyncAccountMobilePushData extends BaseMobilePushData { type: 'sync-account'; } export interface CoachProgramFinishesNextWeekMobilePushData extends BaseMobilePushData { type: 'coach-program-finishes-next-week'; } export interface CoachProgramStartsTodayMobilePushData extends BaseMobilePushData { type: 'coach-program-starts-today'; } export interface ChatUpdateMobilePushData extends BaseMobilePushData { type: 'chat-update'; additionalHevyData: HevyChatUpdateMobilePushData; } export interface CoachLoggedYourWorkoutMobilePushData extends BaseMobilePushData { type: 'coach-logged-your-workout'; additionalHevyData: { workoutId: string; }; deeplink: string; } export interface CoachLoggedYourMeasurementsMobilePushData extends BaseMobilePushData { type: 'coach-logged-your-measurements'; deeplink: string; } export interface MonthlyReportMobilePushData extends BaseMobilePushData { type: 'monthly-report'; deeplink: string; } export interface GracePeriodEnterMobilePushData extends BaseMobilePushData { type: 'grace-period-enter'; deeplink: string; } export interface GracePeriodResolveMobilePushData extends BaseMobilePushData { type: 'grace-period-resolve'; deeplink: string; } export interface NewNotificationMobilePushData extends BaseMobilePushData { type: 'new-notification'; additionalHevyData: { notificationDateISO: string; }; } export interface LiveWorkoutUpdateMobilePushData extends BaseMobilePushData { type: 'live-workout-update'; } export interface LiveWorkoutDeleteMobilePushData extends BaseMobilePushData { type: 'live-workout-delete'; additionalHevyData: { workoutId: string; }; } export interface LiveWorkoutCommentReceived extends BaseMobilePushData { type: 'live-workout-comment-received'; additionalHevyData: { username: string; profile_image: string | null; comment: string; }; } export type MobilePushData = ChatUpdateMobilePushData | SyncCustomExercisesAndCoachCustomizationsMobilePushData | SyncWorkoutsMobilePushData | SyncRoutineFoldersMobilePushData | SyncRoutinesMobilePushData | SyncAccountMobilePushData | ProStatusChangedPushMobilePushData | HevyProSubscriptionRenewedMobilePushData | CoachProgramChangedMobilePushData | CoachDataChangedMobilePushData | ContactOnHevyMobilePushData | CoachClientInviteMobilePushData | AcceptFollowRequestMobilePushData | FollowRequestMobilePushData | FollowMobilePushData | WorkoutLikeMobilePushData | WorkoutCommentLikeMobilePushData | WorkoutCommentMentionMobilePushData | WorkoutCommentDiscussionMobilePushData | WorkoutCommentReplyMobilePushData | WorkoutCommentMobilePushData | WorkoutMentionMobilePushData | WorkoutCompleteMobilePushData | CoachProgramFinishesNextWeekMobilePushData | CoachProgramStartsTodayMobilePushData | CoachLoggedYourWorkoutMobilePushData | CoachLoggedYourMeasurementsMobilePushData | MonthlyReportMobilePushData | GracePeriodEnterMobilePushData | GracePeriodResolveMobilePushData | NewNotificationMobilePushData | LiveWorkoutUpdateMobilePushData | LiveWorkoutDeleteMobilePushData | LiveWorkoutCommentReceived;