Function create_role_notification

Source
pub async fn create_role_notification(
    pool: &Pool<MySql>,
    role_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<RoleNotification>
Expand description

Creates a new notification for a role.

This function inserts a new role notification record that will be visible to all users with the specified role.

§Arguments

  • pool - Database connection pool for executing the query
  • role_id - ID of the role to notify
  • message - The notification message text
  • notification_type - Type of notification (info, warning, error, success)
  • org_id - Optional organization ID related to the notification
  • app_id - Optional application ID related to the notification
  • importance - Optional importance level (default is “normal”)
  • action_url - Optional URL for a related action
  • action_label - Optional label for the action button
  • expires_at - Optional expiration date for the notification

§Returns

  • Ok(RoleNotification) - Successfully created notification
  • Err(anyhow::Error) - Failed to create notification