github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/notification/center/push_message.go (about)

     1  package center
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/cozy/cozy-stack/pkg/mail"
     7  )
     8  
     9  // PushMessage contains a push notification request.
    10  type PushMessage struct {
    11  	NotificationID string `json:"notification_id"`
    12  	Source         string `json:"source"`
    13  	Title          string `json:"title,omitempty"`
    14  	Message        string `json:"message,omitempty"`
    15  	Priority       string `json:"priority,omitempty"`
    16  	Sound          string `json:"sound,omitempty"`
    17  	Collapsible    bool   `json:"collapsible,omitempty"`
    18  
    19  	Data map[string]interface{} `json:"data,omitempty"`
    20  
    21  	MailFallback *mail.Options `json:"mail_fallback,omitempty"`
    22  }
    23  
    24  // Slug returns the slug of the app that wants to send this push message.
    25  func (pm *PushMessage) Slug() string {
    26  	parts := strings.Split(pm.Source, "/")
    27  	if len(parts) < 3 {
    28  		return ""
    29  	}
    30  	return parts[2]
    31  }