workspace avatar and send builded creative
This commit is contained in:
@@ -1439,7 +1439,7 @@ func (s *PurchaseOptionalDetails) createPurchase(b *bot.Bot, jwt string) {
|
||||
}
|
||||
|
||||
for _, placement := range placements.Placements {
|
||||
creativePreview, err := b.Backend.BuildPlacementCreative(
|
||||
_, err := b.Backend.BuildPlacementCreative(
|
||||
context.Background(),
|
||||
jwt,
|
||||
b.Session.WorkspaceID,
|
||||
@@ -1450,12 +1450,6 @@ func (s *PurchaseOptionalDetails) createPurchase(b *bot.Bot, jwt string) {
|
||||
log.Error().Err(err).Msg("Failed to build placement creative")
|
||||
continue
|
||||
}
|
||||
|
||||
channelName := s.formatChannelName(placement)
|
||||
header := fmt.Sprintf("<b>Канал:</b> %s", channelName)
|
||||
b.SendMessage(header, b.ChatID, &echotron.MessageOptions{ParseMode: echotron.HTML})
|
||||
|
||||
s.sendCreativePreview(b, creativePreview)
|
||||
}
|
||||
|
||||
b.SetState(&Placements{
|
||||
@@ -1580,36 +1574,3 @@ func (s *PurchaseOptionalDetails) normalizePurchaseType() (*string, bool) {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PurchaseOptionalDetails) formatChannelName(placement backend.PlacementOutput) string {
|
||||
if placement.Channel.Title != nil && *placement.Channel.Title != "" {
|
||||
return *placement.Channel.Title
|
||||
}
|
||||
if placement.Channel.Username != nil && *placement.Channel.Username != "" {
|
||||
return "@" + *placement.Channel.Username
|
||||
}
|
||||
return "Без названия"
|
||||
}
|
||||
|
||||
func (s *PurchaseOptionalDetails) sendCreativePreview(
|
||||
b *bot.Bot,
|
||||
creative *backend.CreativePreviewOutput,
|
||||
) {
|
||||
editor := CreativeEditorFields{
|
||||
Text: &creative.Text,
|
||||
MediaType: creative.MediaType,
|
||||
MediaFileID: creative.MediaFileID,
|
||||
}
|
||||
|
||||
if len(creative.Buttons) > 0 {
|
||||
editor.Buttons = make([]InlineButton, 0, len(creative.Buttons))
|
||||
for _, btn := range creative.Buttons {
|
||||
editor.Buttons = append(editor.Buttons, InlineButton{
|
||||
Text: btn.Text,
|
||||
URL: btn.URL,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
editor.SendCreativePreview(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user