pub async fn create_user_notification(
pool: &Pool<MySql>,
user_id: i64,
message: &str,
notification_type: &str,
org_id: Option<i64>,
app_id: Option<i64>,
importance: Option<&str>,
action_url: Option<&str>,
action_label: Option<&str>,
expires_at: Option<DateTime<Utc>>,
) -> Result<UserNotification>Expand description
Creates a new notification for a user.
This function inserts a new user notification record with the provided parameters. It handles both required fields and optional fields.
§Arguments
pool- Database connection pool for executing the queryuser_id- ID of the user to notifymessage- The notification message textnotification_type- Type of notification (info, warning, error, success)org_id- Optional organization ID related to the notificationapp_id- Optional application ID related to the notificationimportance- Optional importance level (default is “normal”)action_url- Optional URL for a related actionaction_label- Optional label for the action buttonexpires_at- Optional expiration date for the notification
§Returns
Ok(UserNotification)- Successfully created notification, including database-assigned fieldsErr(anyhow::Error)- Failed to create notification