Skip to main content

πŸ“’ 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​

FieldTypeDescription
iduint32Unique notification ID
user_iduint32ID of the user receiving the notification
org_iduint32Organization ID
typestringType/category of the notification
titlestringNotification title
messagestringNotification content/message
notification_statusstringStatus (e.g., unread, read)
redirect_urlstringURL for redirection on click
applicationstringApp where the notification is relevant
modulestringSubsection/module within the application
metadataKeyValuePair[] / JSONAdditional structured metadata (JSON)
viewed_attimestampTime when the notification was viewed
created_attimestampCreation timestamp
updated_attimestampLast update timestamp
created_byuint32Creator user ID
updated_byuint32Modifier user ID

βœ‰οΈ Email Structure​

Email Fields​

FieldTypeDescription
iduint32Unique email ID
subjectstringEmail subject
bodystringEmail body (text or HTML)
cc[]stringCarbon copy recipients
bcc[]stringBlind carbon copy recipients
fromstringSender email address
to[]stringRecipient list
variablesmap<string, any>Template variables to render dynamic content
templatestringTemplate identifier/name
attachment[]stringList of attachment URLs or file references
messagestringStatus or feedback message
status_codesuint32Optional status codes (e.g., delivery status)

πŸ› οΈ Services​

NotificationService​

RPC MethodRequest TypeResponse TypeDescription
SendEmailSendEmailRequestCheckResponseSends an email to recipients
CreateNotificationCreateNotificationRequestCheckResponseCreates a notification for a user/org
GetNotificationsByUserIDGetNotificationsByUserIDRequestNotificationResponseFetches notifications for a user
GetNotificationsByOrgIDGetNotificationsByOrgIDRequestNotificationResponseFetches all notifications for an org

πŸ“¦ Go Models Overview​

models.Notification​

Represents a notification stored in the relational database using GORM.

FieldTypeNotes
IDuint32Primary key, auto-increment
UserIDuint32User receiving the notification
OrgIDuint32Organization ID
TypestringCategory/type of notification
TitlestringTitle of the notification
MessagestringMessage body
NotificationStatusstringStatus (e.g., read/unread)
RedirectURLstringURL to redirect on click
ApplicationstringApplication identifier
ModulestringModule within the application
MetadataMetadata (JSONB)Extra data stored as JSON
ViewedAttime.TimeWhen it was viewed
CreatedAttime.TimeAuto-managed by GORM
UpdatedAttime.TimeAuto-managed by GORM
CreatedByuint32Creator’s user ID
UpdatedByuint32Modifier’s user ID

models.NotificationEmail​

GORM model for representing sent email records.

FieldTypeNotes
IDuint32Primary key
SubjectstringEmail subject
BodystringEmail content
CC / BCC[]stringEmail addresses
FromstringSender
To[]stringRecipients
Variablesmap[string]interfaceTemplate variables (JSONB)
TemplatestringEmail template name
Attachment[]stringEmail attachments
MessagestringResponse message
StatusCodesuint32Response or delivery status

Metadata Type​

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.