add fix for settings voice in donat
This commit is contained in:
parent
61737b124f
commit
9e2822e70e
@ -687,7 +687,7 @@ func InitNewStreamer(donatService model.DonatService) echo.HandlerFunc {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param streamer-id path string true "Login стримера"
|
// @Param streamer-id path string true "Login стримера"
|
||||||
// @Success 200 {object} model.PlayingDonat "Donat data"
|
// @Success 200 {object} model.PlayingDonatResponse "Donat data"
|
||||||
// @Failure 400 {object} echo.HTTPError "Bad request"
|
// @Failure 400 {object} echo.HTTPError "Bad request"
|
||||||
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
|
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
|
||||||
// @Failure 422 {object} echo.HTTPError "Validation error"
|
// @Failure 422 {object} echo.HTTPError "Validation error"
|
||||||
|
@ -782,7 +782,7 @@ const docTemplate = `{
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "Donat data",
|
"description": "Donat data",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/donat-widget_internal_model.PlayingDonat"
|
"$ref": "#/definitions/donat-widget_internal_model.PlayingDonatResponse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
@ -2039,7 +2039,7 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"donat-widget_internal_model.PlayingDonat": {
|
"donat-widget_internal_model.PlayingDonatResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"amount": {
|
"amount": {
|
||||||
@ -2055,11 +2055,33 @@ const docTemplate = `{
|
|||||||
"image_link": {
|
"image_link": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"languages": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/donat-widget_internal_model.Language"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"min_price": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"order_id": {
|
"order_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"scenery": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"voice_enabled": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"voice_sound_percent": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"voice_speed": {
|
||||||
|
"description": "Добавляем новые поля для настроек голоса",
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -775,7 +775,7 @@
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "Donat data",
|
"description": "Donat data",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/donat-widget_internal_model.PlayingDonat"
|
"$ref": "#/definitions/donat-widget_internal_model.PlayingDonatResponse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
@ -2032,7 +2032,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"donat-widget_internal_model.PlayingDonat": {
|
"donat-widget_internal_model.PlayingDonatResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"amount": {
|
"amount": {
|
||||||
@ -2048,11 +2048,33 @@
|
|||||||
"image_link": {
|
"image_link": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"languages": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/donat-widget_internal_model.Language"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"min_price": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"order_id": {
|
"order_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"scenery": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"voice_enabled": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"voice_sound_percent": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"voice_speed": {
|
||||||
|
"description": "Добавляем новые поля для настроек голоса",
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -395,7 +395,7 @@ definitions:
|
|||||||
example: online
|
example: online
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
donat-widget_internal_model.PlayingDonat:
|
donat-widget_internal_model.PlayingDonatResponse:
|
||||||
properties:
|
properties:
|
||||||
amount:
|
amount:
|
||||||
type: integer
|
type: integer
|
||||||
@ -406,10 +406,25 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
image_link:
|
image_link:
|
||||||
type: string
|
type: string
|
||||||
|
languages:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/donat-widget_internal_model.Language'
|
||||||
|
type: array
|
||||||
|
min_price:
|
||||||
|
type: integer
|
||||||
order_id:
|
order_id:
|
||||||
type: string
|
type: string
|
||||||
|
scenery:
|
||||||
|
type: string
|
||||||
text:
|
text:
|
||||||
type: string
|
type: string
|
||||||
|
voice_enabled:
|
||||||
|
type: boolean
|
||||||
|
voice_sound_percent:
|
||||||
|
type: integer
|
||||||
|
voice_speed:
|
||||||
|
description: Добавляем новые поля для настроек голоса
|
||||||
|
type: string
|
||||||
type: object
|
type: object
|
||||||
donat-widget_internal_model.UpdateFilterSettings:
|
donat-widget_internal_model.UpdateFilterSettings:
|
||||||
properties:
|
properties:
|
||||||
@ -1026,7 +1041,7 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: Donat data
|
description: Donat data
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/donat-widget_internal_model.PlayingDonat'
|
$ref: '#/definitions/donat-widget_internal_model.PlayingDonatResponse'
|
||||||
"400":
|
"400":
|
||||||
description: Bad request
|
description: Bad request
|
||||||
schema:
|
schema:
|
||||||
|
@ -104,7 +104,7 @@ type DonatService interface {
|
|||||||
GetDonatModeration(ctx context.Context, streamerID int) (DonationModeration, error)
|
GetDonatModeration(ctx context.Context, streamerID int) (DonationModeration, error)
|
||||||
ModerateDonation(ctx context.Context, donatID, streamerID int, updateModel ModerationDonat) error
|
ModerateDonation(ctx context.Context, donatID, streamerID int, updateModel ModerationDonat) error
|
||||||
|
|
||||||
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonat, error)
|
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonatResponse, error)
|
||||||
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
||||||
UpdateAvatarStreamer(token, avatarId string) error
|
UpdateAvatarStreamer(token, avatarId string) error
|
||||||
}
|
}
|
||||||
|
@ -335,6 +335,22 @@ type PlayingDonat struct {
|
|||||||
OrderID string `json:"order_id"`
|
OrderID string `json:"order_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlayingDonatResponse struct {
|
||||||
|
Duration int `json:"duration" example:"30"`
|
||||||
|
Image *string `json:"image_link"`
|
||||||
|
Audio *string `json:"audio_link"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
Amount int `json:"amount"`
|
||||||
|
OrderID string `json:"order_id"`
|
||||||
|
// Добавляем новые поля для настроек голоса
|
||||||
|
VoiceSpeed string `json:"voice_speed,omitempty"`
|
||||||
|
Scenery string `json:"scenery,omitempty"`
|
||||||
|
VoiceSoundPercent int `json:"voice_sound_percent,omitempty"`
|
||||||
|
MinPrice int `json:"min_price,omitempty"`
|
||||||
|
Languages []Language `json:"languages,omitempty"`
|
||||||
|
VoiceEnabled bool `json:"voice_enabled"`
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateLoginBody struct {
|
type UpdateLoginBody struct {
|
||||||
AccountID int `json:"account_id"`
|
AccountID int `json:"account_id"`
|
||||||
Login string `json:"login"`
|
Login string `json:"login"`
|
||||||
|
@ -709,50 +709,70 @@ func replaceFilteredWords(text string, words []string) string {
|
|||||||
func (donatService *ServiceDonat) GetPlayingDonat(
|
func (donatService *ServiceDonat) GetPlayingDonat(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
streamerID int,
|
streamerID int,
|
||||||
) (model.PlayingDonat, error) {
|
) (model.PlayingDonatResponse, error) {
|
||||||
playingDonat, err := donatService.donatRepo.GetPlayingDonat(ctx, streamerID)
|
playingDonat, err := donatService.donatRepo.GetPlayingDonat(ctx, streamerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to get playing donat", "error", err)
|
slog.Error("Failed to get playing donat", "error", err)
|
||||||
return model.PlayingDonat{}, err
|
return model.PlayingDonatResponse{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response := model.PlayingDonatResponse{
|
||||||
|
Duration: playingDonat.Duration,
|
||||||
|
Image: playingDonat.Image,
|
||||||
|
Audio: playingDonat.Audio,
|
||||||
|
Text: playingDonat.Text,
|
||||||
|
Amount: playingDonat.Amount,
|
||||||
|
OrderID: playingDonat.OrderID,
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredSettings, err := donatService.GetFiltersSettings(ctx, streamerID)
|
filteredSettings, err := donatService.GetFiltersSettings(ctx, streamerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to get filtered words", "error", err)
|
slog.Error("Failed to get filtered words", "error", err)
|
||||||
return model.PlayingDonat{}, err
|
return model.PlayingDonatResponse{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
voiceSettings, err := donatService.donatRepo.GetVoiceSettingsByStreamerID(ctx, streamerID)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("Failed to get voice settings", "error", err)
|
||||||
|
return model.PlayingDonatResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(filteredSettings.FilteredWords) > 0 {
|
if len(filteredSettings.FilteredWords) > 0 {
|
||||||
playingDonat.Text = donatService.replaceFilteredWords(playingDonat.Text, filteredSettings.FilteredWords)
|
response.Text = donatService.replaceFilteredWords(response.Text, filteredSettings.FilteredWords)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filteredSettings.EnableLinks {
|
if !filteredSettings.EnableLinks {
|
||||||
playingDonat.Text = donatService.replaceLinks(playingDonat.Text)
|
response.Text = donatService.replaceLinks(response.Text)
|
||||||
}
|
}
|
||||||
|
|
||||||
if playingDonat.OrderID == "" {
|
response.VoiceSpeed = voiceSettings.VoiceSpeed
|
||||||
return playingDonat, nil
|
response.Scenery = voiceSettings.Scenery
|
||||||
}
|
response.VoiceSoundPercent = voiceSettings.VoiceSoundPercent
|
||||||
|
response.MinPrice = voiceSettings.MinPrice
|
||||||
|
response.Languages = voiceSettings.Languages
|
||||||
|
response.VoiceEnabled = voiceSettings.Enable
|
||||||
|
|
||||||
if playingDonat.Image != nil {
|
if response.OrderID != "" {
|
||||||
imageUuid, err := uuid.Parse(*playingDonat.Image)
|
if response.Image != nil {
|
||||||
if err != nil {
|
imageUuid, err := uuid.Parse(*response.Image)
|
||||||
return model.PlayingDonat{}, err
|
if err != nil {
|
||||||
|
return model.PlayingDonatResponse{}, err
|
||||||
|
}
|
||||||
|
fileUrl := donatService.storage.DownloadLink(imageUuid)
|
||||||
|
response.Image = &fileUrl
|
||||||
}
|
}
|
||||||
fileUrl := donatService.storage.DownloadLink(imageUuid)
|
|
||||||
playingDonat.Image = &fileUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
if playingDonat.Audio != nil {
|
if response.Audio != nil {
|
||||||
audioUuid, err := uuid.Parse(*playingDonat.Audio)
|
audioUuid, err := uuid.Parse(*response.Audio)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.PlayingDonat{}, err
|
return model.PlayingDonatResponse{}, err
|
||||||
|
}
|
||||||
|
fileUrl := donatService.storage.DownloadLink(audioUuid)
|
||||||
|
response.Audio = &fileUrl
|
||||||
}
|
}
|
||||||
fileUrl := donatService.storage.DownloadLink(audioUuid)
|
|
||||||
playingDonat.Audio = &fileUrl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return playingDonat, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (donatService *ServiceDonat) UpdateStreamerLogin(
|
func (donatService *ServiceDonat) UpdateStreamerLogin(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user