Add /preview/* routes

This commit is contained in:
2024-06-12 00:35:06 +02:00
parent 64709920f7
commit 80b1351bd2
9 changed files with 924 additions and 102 deletions

View File

@@ -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,