package types import "time" // EventTypeConversation is the fetchEvents type for chat list sync. const EventTypeConversation EventType = "conversation" // ConversationEventData builds a conversation fetchEvents payload. func ConversationEventData(operation string, conversations []map[string]interface{}) map[string]interface{} { if conversations == nil { conversations = []map[string]interface{}{} } return map[string]interface{}{ "operation": operation, "conversations": conversations, } } // ConversationEntry builds one conversation object for the Web AIM client. func ConversationEntry(aimID, displayID, message, msgID, sender string, sent bool, unread int) map[string]interface{} { entry := map[string]interface{}{ "aimId": aimID, "displayId": displayID, "active": 0, "unreadCount": unread, } if message != "" { entry["lastIM"] = map[string]interface{}{ "message": message, "msgId": msgID, "sender": sender, "sent": sent, "timestamp": float64(time.Now().Unix()), } } return entry }