-
Notifications
You must be signed in to change notification settings - Fork 4
/
prompt.go
45 lines (39 loc) · 1.05 KB
/
prompt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package model
import (
"context"
"time"
"github.com/bcc-code/bcc-media-platform/backend/common"
"github.com/bcc-code/bcc-media-platform/backend/user"
"github.com/bcc-code/bcc-media-platform/backend/utils"
)
func PromptFrom(ctx context.Context, i *common.Prompt) Prompt {
ginCtx, _ := utils.GinCtx(ctx)
languages := user.GetLanguagesFromCtx(ginCtx)
title := i.Title.Get(languages)
//secondaryTitle := i.SecondaryTitle.GetValueOrNil(languages)
from := i.From.Format(time.RFC3339)
to := i.To.Format(time.RFC3339)
switch i.Type {
case "survey":
return &SurveyPrompt{
ID: i.ID.String(),
Title: title,
SecondaryTitle: i.SecondaryTitle.GetValueOrNil(languages),
From: from,
To: to,
Survey: &Survey{
ID: i.SurveyID.UUID.String(),
},
}
}
return &SurveyPrompt{
ID: i.ID.String(),
Title: title,
SecondaryTitle: i.SecondaryTitle.GetValueOrNil(languages),
From: from,
To: to,
Survey: &Survey{
ID: i.SurveyID.UUID.String(),
},
}
}