Add /preview/* routes
This commit is contained in:
@@ -41,6 +41,16 @@ func (c Channel) WithSubscription(sub *Subscription) ChannelWithSubscription {
|
||||
}
|
||||
}
|
||||
|
||||
func (c Channel) JSONPreview() ChannelPreviewJSON {
|
||||
return ChannelPreviewJSON{
|
||||
ChannelID: c.ChannelID,
|
||||
OwnerUserID: c.OwnerUserID,
|
||||
InternalName: c.InternalName,
|
||||
DisplayName: c.DisplayName,
|
||||
DescriptionName: c.DescriptionName,
|
||||
}
|
||||
}
|
||||
|
||||
type ChannelWithSubscription struct {
|
||||
Channel
|
||||
Subscription *Subscription
|
||||
@@ -74,6 +84,14 @@ type ChannelWithSubscriptionJSON struct {
|
||||
Subscription *SubscriptionJSON `json:"subscription"`
|
||||
}
|
||||
|
||||
type ChannelPreviewJSON struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
type ChannelDB struct {
|
||||
ChannelID ChannelID `db:"channel_id"`
|
||||
OwnerUserID UserID `db:"owner_user_id"`
|
||||
|
@@ -5,7 +5,7 @@ package models
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/enums"
|
||||
|
||||
const ChecksumEnumGenerator = "5b115c5f107801af608630d2c5adce57cd4b050d176c8cd3db5c132020bf153c" // GoExtVersion: 0.0.463
|
||||
const ChecksumEnumGenerator = "e500346e3f60b3abf78558ec3df128c3be2a1cefa71c4f1feba9293d14eb85d1" // GoExtVersion: 0.0.463
|
||||
|
||||
// ================================ ClientType ================================
|
||||
//
|
||||
|
@@ -15,7 +15,7 @@ import "reflect"
|
||||
import "regexp"
|
||||
import "strings"
|
||||
|
||||
const ChecksumCharsetIDGenerator = "5b115c5f107801af608630d2c5adce57cd4b050d176c8cd3db5c132020bf153c" // GoExtVersion: 0.0.463
|
||||
const ChecksumCharsetIDGenerator = "e500346e3f60b3abf78558ec3df128c3be2a1cefa71c4f1feba9293d14eb85d1" // GoExtVersion: 0.0.463
|
||||
|
||||
const idlen = 24
|
||||
|
||||
|
@@ -92,6 +92,17 @@ func (k KeyToken) JSON() KeyTokenJSON {
|
||||
}
|
||||
}
|
||||
|
||||
func (k KeyToken) JSONPreview() KeyTokenPreviewJSON {
|
||||
return KeyTokenPreviewJSON{
|
||||
KeyTokenID: k.KeyTokenID,
|
||||
Name: k.Name,
|
||||
OwnerUserID: k.OwnerUserID,
|
||||
AllChannels: k.AllChannels,
|
||||
Channels: k.Channels,
|
||||
Permissions: k.Permissions.String(),
|
||||
}
|
||||
}
|
||||
|
||||
type KeyTokenJSON struct {
|
||||
KeyTokenID KeyTokenID `json:"keytoken_id"`
|
||||
Name string `json:"name"`
|
||||
@@ -109,6 +120,15 @@ type KeyTokenWithTokenJSON struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type KeyTokenPreviewJSON struct {
|
||||
KeyTokenID KeyTokenID `json:"keytoken_id"`
|
||||
Name string `json:"name"`
|
||||
OwnerUserID UserID `json:"owner_user_id"`
|
||||
AllChannels bool `json:"all_channels"`
|
||||
Channels []ChannelID `json:"channels"`
|
||||
Permissions string `json:"permissions"`
|
||||
}
|
||||
|
||||
func (j KeyTokenJSON) WithToken(tok string) KeyTokenWithTokenJSON {
|
||||
return KeyTokenWithTokenJSON{
|
||||
KeyTokenJSON: j,
|
||||
|
@@ -116,6 +116,13 @@ func (u User) MaxTimestampDiffHours() int {
|
||||
return 24
|
||||
}
|
||||
|
||||
func (u User) JSONPreview() UserPreviewJSON {
|
||||
return UserPreviewJSON{
|
||||
UserID: u.UserID,
|
||||
Username: u.Username,
|
||||
}
|
||||
}
|
||||
|
||||
type UserJSON struct {
|
||||
UserID UserID `json:"user_id"`
|
||||
Username *string `json:"username"`
|
||||
@@ -137,6 +144,11 @@ type UserJSON struct {
|
||||
MaxUserMessageIDLength int `json:"max_user_message_id_length"`
|
||||
}
|
||||
|
||||
type UserPreviewJSON struct {
|
||||
UserID UserID `json:"user_id"`
|
||||
Username *string `json:"username"`
|
||||
}
|
||||
|
||||
type UserJSONWithClientsAndKeys struct {
|
||||
UserJSON
|
||||
Clients []ClientJSON `json:"clients"`
|
||||
|
Reference in New Issue
Block a user