chore: import clean Agent Desk snapshot (2/7)
This commit is contained in:
35
internal/handlers/api/customer_handler.go
Normal file
35
internal/handlers/api/customer_handler.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"agent-desk/internal/pkg/config"
|
||||
"agent-desk/internal/pkg/httpx"
|
||||
"agent-desk/internal/pkg/openidentity"
|
||||
"agent-desk/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CustomerPostSession_exchange(ctx *gin.Context) {
|
||||
channel := services.ChannelService.GetEnabledChannel(ctx)
|
||||
if channel == nil {
|
||||
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0209"))
|
||||
return
|
||||
}
|
||||
identity := config.Current().Identity
|
||||
externalUser, err := openidentity.GetExternalUser(ctx, openidentity.Secrets{
|
||||
UserToken: services.ChannelService.GetUserTokenSecret(channel),
|
||||
IdentityHMAC: identity.Secret,
|
||||
IdentityMaxAge: identity.MaxAge(),
|
||||
ChannelID: channel.ChannelID,
|
||||
})
|
||||
if err != nil {
|
||||
httpx.WriteJSON(ctx, err)
|
||||
return
|
||||
}
|
||||
resp, err := services.CustomerSessionService.Exchange(channel, *externalUser)
|
||||
if err != nil {
|
||||
httpx.WriteJSON(ctx, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(ctx, resp)
|
||||
}
|
||||
Reference in New Issue
Block a user