notification/model.go

130 lines
2.9 KiB
Go
Raw Permalink Normal View History

2021-12-03 03:54:59 +00:00
package notification
2022-10-10 03:27:52 +00:00
import "git.selly.red/Selly-Modules/natsio"
2021-12-03 03:54:59 +00:00
// Config ...
type Config struct {
APIKey string
Nats natsio.Config
}
// PushRequest ...
type PushRequest struct {
2023-03-27 04:42:26 +00:00
Title string `json:"title"`
Body string `json:"body"`
Data string `json:"data"`
Users []string `json:"users"`
Label string `json:"label,omitempty"`
Category string `json:"category,omitempty"`
Sound *Sound `json:"sound,omitempty"`
Link string `json:"link"` // for webpush
Order int `json:"order"` // for sort
DisplayUntil int64 `json:"displayUntil"` // time.Unix
SaveNotification bool `json:"saveNotification"`
2021-12-22 02:54:23 +00:00
}
// Sound ...
type Sound struct {
IOSFileName string `json:"iosFileName"`
AndroidChannel string `json:"androidChannel"`
2021-12-03 03:54:59 +00:00
}
// PushResponse ...
type PushResponse struct {
RequestID string `json:"requestId"`
}
type pushRequest struct {
2022-11-14 08:54:11 +00:00
PushRequest
Version string `json:"version"`
APIKey string `json:"apiKey"`
SendBy string `json:"sendBy"`
2021-12-03 03:54:59 +00:00
}
// Query ...
type Query struct {
User string `json:"user"`
Category string `json:"category,omitempty"`
2022-11-15 04:46:41 +00:00
Status string `json:"status"`
2021-12-03 03:54:59 +00:00
Page int64 `json:"page,omitempty"`
Limit int64 `json:"limit,omitempty"`
2022-11-21 08:33:31 +00:00
Sort string `json:"sort,omitempty"` // SortDefault, SortOrderDesc, SortOrderAsc
2021-12-03 03:54:59 +00:00
}
type query struct {
2022-11-14 08:54:11 +00:00
APIKey string `json:"apiKey"`
Query
2021-12-03 03:54:59 +00:00
}
2021-12-03 04:09:25 +00:00
// Notification ...
type Notification struct {
ID string `json:"id"`
Category string `json:"category,omitempty"`
Title string `json:"title"`
Body string `json:"body"`
IsRead bool `json:"isRead"`
Data string `json:"data,omitempty"`
CreatedAt string `json:"createdAt"`
LastPushAt string `json:"lastPushAt"`
}
// ListNotificationResponse ...
type ListNotificationResponse struct {
List []Notification `json:"list"`
Total int64 `json:"total"`
Limit int64 `json:"limit"`
}
// Read ...
2021-12-03 03:54:59 +00:00
type Read struct {
2021-12-03 09:56:48 +00:00
ID string `json:"id"`
2021-12-03 03:54:59 +00:00
}
type read struct {
APIKey string `json:"apiKey"`
ID string `json:"id"`
}
// CountUnread ...
type CountUnread struct {
User string `json:"user"`
2021-12-03 09:56:48 +00:00
Category string `json:"category,omitempty"`
2021-12-03 03:54:59 +00:00
}
2021-12-03 04:25:50 +00:00
// CountUnreadResponse ...
type CountUnreadResponse struct {
2022-11-14 08:54:11 +00:00
List []CategoryCount `json:"list"`
}
type CategoryCount struct {
Category string `json:"category"`
TotalUnread int64 `json:"totalUnread"`
2021-12-03 04:25:50 +00:00
}
2021-12-03 03:54:59 +00:00
type countUnread struct {
2022-11-14 08:54:11 +00:00
CountUnread
APIKey string `json:"apiKey"`
2021-12-03 03:54:59 +00:00
}
2021-12-06 04:02:29 +00:00
// CommonError ...
type CommonError struct {
Error string `json:"error"`
}
// Subscribe ...
type Subscribe struct {
Tokens []string `json:"tokens"`
Topic string `json:"topic"`
}
type subscribe struct {
Subscribe
APIKey string `json:"apiKey"`
}
2022-11-14 08:54:11 +00:00
// ReadAll ...
type ReadAll struct {
User string `json:"user"`
Category string `json:"category,omitempty"`
}