Skip to content

Issue #46 — Backend: Notification Creation Provider #679

@yusuftomilola

Description

@yusuftomilola

Location: backend/src/notifications/providers/create-notification.provider.ts

Description

Other modules — bookings, payments, invoices — need a simple way to create in-app notifications for a member after key events. This provider exposes a single notify() method that any module can call to persist a notification record. It has no HTTP endpoint — it is a purely internal service.

Because this provider will be called from outside the NotificationsModule (e.g. from BookingsModule and PaymentsModule), it must be exported from NotificationsModule so it can be injected as a dependency in those modules.

Acceptance Criteria

  • A CreateNotificationProvider class is created at backend/src/notifications/providers/create-notification.provider.ts
  • The provider exposes a notify(userId: string, type: NotificationType, title: string, message: string): Promise<Notification> method
  • The method creates and saves a Notification record and returns it
  • All notification creation calls are fire-and-forget — callers should wrap calls with .catch(() => void 0) so a failed notification never breaks the calling flow
  • CreateNotificationProvider is registered in NotificationsModule providers and exported so it can be injected in other modules
  • NotificationsModule is imported into the following modules so CreateNotificationProvider is available:
    • backend/src/bookings/bookings.module.ts
    • backend/src/payments/payments.module.ts
  • The provider is wired up with fire-and-forget calls at the following trigger points (alongside the existing email calls in those providers):
    • create-booking.provider.tsBOOKING_CREATED"Booking Created" / "Your booking for <workspace> has been received and is pending confirmation."
    • cancel-booking.provider.tsBOOKING_CANCELLED"Booking Cancelled" / "Your booking for <workspace> has been cancelled."
    • handle-webhook.provider.ts (charge.success) → PAYMENT_SUCCESS"Payment Successful" / "Your payment of ₦<amount> for <workspace> was successful."
    • handle-webhook.provider.ts (charge.failed) → PAYMENT_FAILED"Payment Failed" / "Your payment of ₦<amount> could not be processed. Please try again."
  • npx tsc --noEmit passes with no errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions