import { messaging } from '../config/firebase'

/**
 * Send a push notification to a user's device.
 * Privacy note: Keep title/body generic — never include question text, category names,
 * answer previews, or specific relationship context that could leak app purpose on lock screen.
 */
export async function sendPushToUser(
  fcmToken: string,
  title: string,
  body: string,
  data?: Record<string, string>
): Promise<void> {
  await messaging().send({
    token: fcmToken,
    notification: { title, body },
    data,
    android: {
      priority: 'high',
      notification: { channelId: 'partner_activity' },
    },
  })
}

/**
 * Notify a user that their partner has answered a question.
 * Privacy: Use generic wording that doesn’t reveal question content, categories,
 * answer previews, or even the partner's name on the lock screen.
 */
export async function sendPartnerAnsweredNotification(
  partnerFcmToken: string,
  _partnerName: string
): Promise<void> {
  await sendPushToUser(
    partnerFcmToken,
    'You have something new from your partner',
    'Tap to open Closer and see what they shared.',
    { type: 'partner_answered' }
  )
}

/**
 * Remind a user to answer a question.
 * Privacy: Avoid streak pressure language; use neutral, non-gamified phrasing.
 */
export async function sendStreakReminderNotification(
  fcmToken: string
): Promise<void> {
  await sendPushToUser(
    fcmToken,
    'You have something new in Closer',
    'A moment is waiting for you. Tap to open and share your thoughts.',
    { type: 'streak_reminder' }
  )
}
