feat: add customer online status to conversation response and update UI accordingly
This commit is contained in:
@@ -104,6 +104,14 @@ func (m *WsConnectionManager) FindByTopics(topics []string) []*ClientSession {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m *WsConnectionManager) HasTopic(topic string) bool {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
sessions := m.topics[topic]
|
||||
return len(sessions) > 0
|
||||
}
|
||||
|
||||
func (m *WsConnectionManager) subscribeLocked(session *ClientSession, topic string) {
|
||||
if _, exists := session.Topics[topic]; exists {
|
||||
return
|
||||
|
||||
@@ -386,6 +386,14 @@ func (s *wsService) PublishToTopics(topics []string, event RealtimeEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *wsService) IsVisitorOnline(visitorID string) bool {
|
||||
visitorID = strings.TrimSpace(visitorID)
|
||||
if visitorID == "" {
|
||||
return false
|
||||
}
|
||||
return s.manager.HasTopic(s.visitorTopic(visitorID))
|
||||
}
|
||||
|
||||
func (s *wsService) routeConversationTopics(conversation *models.Conversation) []string {
|
||||
if conversation == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user