Basic room disco info
This commit is contained in:
parent
63f12202d0
commit
7ef32096af
|
@ -1075,13 +1075,10 @@ func (c *Client) GetGroupChats() []*client.Chat {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, id := range chats.ChatIds {
|
for _, id := range chats.ChatIds {
|
||||||
chat, _, _ := c.GetContactByID(id, nil)
|
chat, _, _ := c.GetContactByID(id, nil)
|
||||||
if chat != nil {
|
if chat != nil && c.IsGroup(chat) {
|
||||||
typ := chat.Type.ChatTypeType()
|
|
||||||
if typ == client.TypeChatTypeBasicGroup {
|
|
||||||
groupChats = append(groupChats, chat)
|
groupChats = append(groupChats, chat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("Could not retrieve chats: %v", err)
|
log.Errorf("Could not retrieve chats: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1089,6 +1086,12 @@ func (c *Client) GetGroupChats() []*client.Chat {
|
||||||
return groupChats
|
return groupChats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsGroup determines if a chat is eligible to be represented as MUC
|
||||||
|
func (c *Client) IsGroup(chat *client.Chat) bool {
|
||||||
|
typ := chat.Type.ChatTypeType()
|
||||||
|
return typ == client.TypeChatTypeBasicGroup
|
||||||
|
}
|
||||||
|
|
||||||
// subscribe to a Telegram ID
|
// subscribe to a Telegram ID
|
||||||
func (c *Client) subscribeToID(id int64, chat *client.Chat) {
|
func (c *Client) subscribeToID(id int64, chat *client.Chat) {
|
||||||
var args []args.V
|
var args []args.V
|
||||||
|
|
|
@ -339,20 +339,37 @@ func handleGetDisco(dt discoType, s xmpp.Sender, iq *stanza.IQ) {
|
||||||
|
|
||||||
if dt == discoTypeInfo {
|
if dt == discoTypeInfo {
|
||||||
disco := answer.DiscoInfo()
|
disco := answer.DiscoInfo()
|
||||||
_, ok := toToID(iq.To)
|
toID, toOk := toToID(iq.To)
|
||||||
if ok {
|
if toOk {
|
||||||
disco.AddIdentity("", "account", "registered")
|
disco.AddIdentity("", "account", "registered")
|
||||||
} else {
|
} else {
|
||||||
disco.AddIdentity("Telegram Gateway", "gateway", "telegram")
|
disco.AddIdentity("Telegram Gateway", "gateway", "telegram")
|
||||||
}
|
}
|
||||||
bare, _, ok := splitFrom(iq.From)
|
bare, _, fromOk := splitFrom(iq.From)
|
||||||
if ok {
|
if fromOk {
|
||||||
session, ok := sessions[bare]
|
session, sessionOk := sessions[bare]
|
||||||
if ok && session.Session.MUC {
|
if sessionOk && session.Session.MUC {
|
||||||
|
if toOk {
|
||||||
|
chat, _, err := session.GetContactByID(toID, nil)
|
||||||
|
if err == nil && session.IsGroup(chat) {
|
||||||
|
disco.AddIdentity(chat.Title, "conference", "text")
|
||||||
|
}
|
||||||
|
|
||||||
|
disco.AddFeatures(
|
||||||
|
"http://jabber.org/protocol/muc",
|
||||||
|
"muc_persistent",
|
||||||
|
"muc_hidden",
|
||||||
|
"muc_membersonly",
|
||||||
|
"muc_unmoderated",
|
||||||
|
"muc_nonanonymous",
|
||||||
|
"muc_unsecured",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
disco.AddFeatures(stanza.NSDiscoItems)
|
disco.AddFeatures(stanza.NSDiscoItems)
|
||||||
disco.AddIdentity("Telegram group chats", "conference", "text")
|
disco.AddIdentity("Telegram group chats", "conference", "text")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
answer.Payload = disco
|
answer.Payload = disco
|
||||||
} else if dt == discoTypeItems {
|
} else if dt == discoTypeItems {
|
||||||
disco := answer.DiscoItems()
|
disco := answer.DiscoItems()
|
||||||
|
|
Loading…
Reference in a new issue