Added Optional channel description name to channel creation, adjusted tests
All checks were successful
Build Docker and Deploy / Build Docker Container (push) Successful in 2m22s
Build Docker and Deploy / Deploy to Server (push) Successful in 11s

This commit is contained in:
2024-02-24 12:20:41 +01:00
parent 51f5f1005a
commit 77cfe75043
4 changed files with 44 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"blackforestbytes.com/simplecloudnotifier/api/apierr"
"blackforestbytes.com/simplecloudnotifier/api/ginresp"
ct "blackforestbytes.com/simplecloudnotifier/db/cursortoken"
"blackforestbytes.com/simplecloudnotifier/db/impl/primary"
"blackforestbytes.com/simplecloudnotifier/models"
"database/sql"
"errors"
@@ -180,6 +181,8 @@ func (h APIHandler) CreateChannel(g *gin.Context) ginresp.HTTPResponse {
type body struct {
Name string `json:"name"`
Subscribe *bool `json:"subscribe"`
Description *string `json:"description"`
}
var u uri
@@ -233,7 +236,15 @@ func (h APIHandler) CreateChannel(g *gin.Context) ginresp.HTTPResponse {
subscribeKey := h.app.GenerateRandomAuthKey()
channel, err := h.database.CreateChannel(ctx, u.UserID, channelDisplayName, channelInternalName, subscribeKey)
cChannel := primary.CreateChanel{
UserId: u.UserID,
IntName: channelInternalName,
SubscribeKey: subscribeKey,
DisplayName: channelDisplayName,
Description: b.Description,
}
channel, err := h.database.CreateChannel(ctx, cChannel)
if err != nil {
return ginresp.APIError(g, 500, apierr.DATABASE_ERROR, "Failed to create channel", err)
}