π’ Notification Service
The Notification Service handles creation, retrieval, and email dispatching of notifications. It supports storing rich metadata, template-based emails, and customizable redirection and categorization options.
π Notification Structureβ
Notification Fieldsβ
| Field | Type | Description |
|---|
id | uint32 | Unique notification ID |
user_id | uint32 | ID of the user receiving the notification |
org_id | uint32 | Organization ID |
type | string | Type/category of the notification |
title | string | Notification title |
message | string | Notification content/message |
notification_status | string | Status (e.g., unread, read) |
redirect_url | string | URL for redirection on click |
application | string | App where the notification is relevant |
module | string | Subsection/module within the application |
metadata | KeyValuePair[] / JSON | Additional structured metadata (JSON) |
viewed_at | timestamp | Time when the notification was viewed |
created_at | timestamp | Creation timestamp |
updated_at | timestamp | Last update timestamp |
created_by | uint32 | Creator user ID |
updated_by | uint32 | Modifier user ID |
βοΈ Email Structureβ
Email Fieldsβ
| Field | Type | Description |
|---|
id | uint32 | Unique email ID |
subject | string | Email subject |
body | string | Email body (text or HTML) |
cc | []string | Carbon copy recipients |
bcc | []string | Blind carbon copy recipients |
from | string | Sender email address |
to | []string | Recipient list |
variables | map<string, any> | Template variables to render dynamic content |
template | string | Template identifier/name |
attachment | []string | List of attachment URLs or file references |
message | string | Status or feedback message |
status_codes | uint32 | Optional status codes (e.g., delivery status) |
π οΈ Servicesβ
NotificationServiceβ
| RPC Method | Request Type | Response Type | Description |
|---|
SendEmail | SendEmailRequest | CheckResponse | Sends an email to recipients |
CreateNotification | CreateNotificationRequest | CheckResponse | Creates a notification for a user/org |
GetNotificationsByUserID | GetNotificationsByUserIDRequest | NotificationResponse | Fetches notifications for a user |
GetNotificationsByOrgID | GetNotificationsByOrgIDRequest | NotificationResponse | Fetches all notifications for an org |
π¦ Go Models Overviewβ
models.Notificationβ
Represents a notification stored in the relational database using GORM.
| Field | Type | Notes |
|---|
ID | uint32 | Primary key, auto-increment |
UserID | uint32 | User receiving the notification |
OrgID | uint32 | Organization ID |
Type | string | Category/type of notification |
Title | string | Title of the notification |
Message | string | Message body |
NotificationStatus | string | Status (e.g., read/unread) |
RedirectURL | string | URL to redirect on click |
Application | string | Application identifier |
Module | string | Module within the application |
Metadata | Metadata (JSONB) | Extra data stored as JSON |
ViewedAt | time.Time | When it was viewed |
CreatedAt | time.Time | Auto-managed by GORM |
UpdatedAt | time.Time | Auto-managed by GORM |
CreatedBy | uint32 | Creatorβs user ID |
UpdatedBy | uint32 | Modifierβs user ID |
models.NotificationEmailβ
GORM model for representing sent email records.
| Field | Type | Notes |
|---|
ID | uint32 | Primary key |
Subject | string | Email subject |
Body | string | Email content |
CC / BCC | []string | Email addresses |
From | string | Sender |
To | []string | Recipients |
Variables | map[string]interface | Template variables (JSONB) |
Template | string | Email template name |
Attachment | []string | Email attachments |
Message | string | Response message |
StatusCodes | uint32 | Response or delivery status |
A custom map[string]interface{} used to scan/store JSONB metadata in PostgreSQL via GORM.
π Notesβ
- Email functionality supports templates, attachments, and dynamic variables.
- Metadata supports flexible structure via JSONB.
- Pagination is supported via
page_number and page_size in list methods.