14e3df64f1
- Introduced RealtimeCustomerSessionRefreshPayload and RealtimeCustomerSessionRefreshEvent types for handling session refresh events. - Updated ws_service to verify customer session and handle session refresh notifications. - Enhanced API client to manage customer session tokens and expiration. - Implemented customer session validation and storage in session storage. - Added functions to exchange and ensure customer sessions. - Updated IM real-time connection to include customer session tokens in WebSocket requests. - Modified SDK and widget configurations to support external IDs and user tokens.
30 lines
746 B
Go
30 lines
746 B
Go
package api
|
|
|
|
import (
|
|
"cs-agent/internal/pkg/openidentity"
|
|
"cs-agent/internal/services"
|
|
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/mlogclub/simple/web"
|
|
)
|
|
|
|
type CustomerController struct {
|
|
Ctx iris.Context
|
|
}
|
|
|
|
func (c *CustomerController) PostSession_exchange() *web.JsonResult {
|
|
channel := services.ChannelService.GetEnabledChannel(c.Ctx)
|
|
if channel == nil {
|
|
return web.JsonErrorMsg("接入渠道不存在或已停用")
|
|
}
|
|
externalUser, err := openidentity.GetExternalUser(c.Ctx, services.ChannelService.GetUserTokenSecret(channel))
|
|
if err != nil {
|
|
return web.JsonError(err)
|
|
}
|
|
resp, err := services.CustomerSessionService.Exchange(channel, *externalUser)
|
|
if err != nil {
|
|
return web.JsonError(err)
|
|
}
|
|
return web.JsonData(resp)
|
|
}
|