2022-11-18 23:12:37 +01:00
|
|
|
package models
|
|
|
|
|
|
|
|
type Channel struct {
|
2024-09-15 21:07:46 +02:00
|
|
|
ChannelID ChannelID `db:"channel_id" json:"channel_id"`
|
|
|
|
OwnerUserID UserID `db:"owner_user_id" json:"owner_user_id"`
|
2024-09-19 19:46:46 +02:00
|
|
|
InternalName string `db:"internal_name" json:"internal_name"` // = InternalName, used for sending, normalized, cannot be changed
|
|
|
|
DisplayName string `db:"display_name" json:"display_name"` // = DisplayName, used for display purposes, can be changed, initially equals InternalName
|
|
|
|
DescriptionName *string `db:"description_name" json:"description_name"` // = DescriptionName, (optional), longer description text, initally nil
|
2024-09-15 21:07:46 +02:00
|
|
|
SubscribeKey string `db:"subscribe_key" json:"subscribe_key" jsonfilter:"INCLUDE_KEY"` // can be nil, depending on endpoint
|
|
|
|
TimestampCreated SCNTime `db:"timestamp_created" json:"timestamp_created"`
|
|
|
|
TimestampLastSent *SCNTime `db:"timestamp_lastsent" json:"timestamp_lastsent"`
|
|
|
|
MessagesSent int `db:"messages_sent" json:"messages_sent"`
|
2024-06-12 00:35:06 +02:00
|
|
|
}
|
|
|
|
|
2022-12-21 18:14:13 +01:00
|
|
|
type ChannelWithSubscription struct {
|
|
|
|
Channel
|
2024-09-15 21:07:46 +02:00
|
|
|
Subscription *Subscription `db:"sub" json:"subscription"`
|
2022-11-18 23:12:37 +01:00
|
|
|
}
|
|
|
|
|
2024-09-15 21:07:46 +02:00
|
|
|
type ChannelPreview struct {
|
2024-06-12 00:35:06 +02:00
|
|
|
ChannelID ChannelID `json:"channel_id"`
|
|
|
|
OwnerUserID UserID `json:"owner_user_id"`
|
|
|
|
InternalName string `json:"internal_name"`
|
|
|
|
DisplayName string `json:"display_name"`
|
|
|
|
DescriptionName *string `json:"description_name"`
|
|
|
|
}
|
|
|
|
|
2024-09-15 21:07:46 +02:00
|
|
|
func (c Channel) WithSubscription(sub *Subscription) ChannelWithSubscription {
|
2022-12-21 18:14:13 +01:00
|
|
|
return ChannelWithSubscription{
|
2024-09-15 21:07:46 +02:00
|
|
|
Channel: c,
|
2022-12-21 18:14:13 +01:00
|
|
|
Subscription: sub,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-15 21:07:46 +02:00
|
|
|
func (c Channel) Preview() ChannelPreview {
|
|
|
|
return ChannelPreview{
|
|
|
|
ChannelID: c.ChannelID,
|
|
|
|
OwnerUserID: c.OwnerUserID,
|
|
|
|
InternalName: c.InternalName,
|
|
|
|
DisplayName: c.DisplayName,
|
|
|
|
DescriptionName: c.DescriptionName,
|
2022-12-21 18:14:13 +01:00
|
|
|
}
|
|
|
|
}
|