aboutsummaryrefslogtreecommitdiff
path: root/xmpp/handlers.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-07-09 00:43:56 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-07-09 00:43:56 +0300
commit63521b8f90af65cad9ca7510be3c2b76307d8090 (patch)
tree441a0f1a2f9923078d26bd6d1662935c08d59f88 /xmpp/handlers.go
parent7ef32096af6017607f70a0b5aa2fbc03925c72d1 (diff)
Extended room disco info
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r--xmpp/handlers.go53
1 files changed, 38 insertions, 15 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 6531983..fde7382 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -340,11 +340,7 @@ func handleGetDisco(dt discoType, s xmpp.Sender, iq *stanza.IQ) {
if dt == discoTypeInfo {
disco := answer.DiscoInfo()
toID, toOk := toToID(iq.To)
- if toOk {
- disco.AddIdentity("", "account", "registered")
- } else {
- disco.AddIdentity("Telegram Gateway", "gateway", "telegram")
- }
+ var isMuc bool
bare, _, fromOk := splitFrom(iq.From)
if fromOk {
session, sessionOk := sessions[bare]
@@ -352,24 +348,51 @@ func handleGetDisco(dt discoType, s xmpp.Sender, iq *stanza.IQ) {
if toOk {
chat, _, err := session.GetContactByID(toID, nil)
if err == nil && session.IsGroup(chat) {
+ isMuc = true
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",
- )
+ disco.AddFeatures(
+ "http://jabber.org/protocol/muc",
+ "muc_persistent",
+ "muc_hidden",
+ "muc_membersonly",
+ "muc_unmoderated",
+ "muc_nonanonymous",
+ "muc_unsecured",
+ )
+ fields := []*stanza.Field{
+ &stanza.Field{
+ Var: "FORM_TYPE",
+ Type: "hidden",
+ ValuesList: []string{"http://jabber.org/protocol/muc#roominfo"},
+ },
+ &stanza.Field{
+ Var: "muc#roominfo_description",
+ Label: "Description",
+ ValuesList: []string{session.GetChatDescription(chat)},
+ },
+ &stanza.Field{
+ Var: "muc#roominfo_occupants",
+ Label: "Number of occupants",
+ ValuesList: []string{strconv.FormatInt(int64(session.GetChatMemberCount(chat)), 10)},
+ },
+ }
+
+ disco.Form = stanza.NewForm(fields, "result")
+ }
} else {
disco.AddFeatures(stanza.NSDiscoItems)
disco.AddIdentity("Telegram group chats", "conference", "text")
}
}
}
+ if toOk {
+ if !isMuc {
+ disco.AddIdentity("", "account", "registered")
+ }
+ } else {
+ disco.AddIdentity("Telegram Gateway", "gateway", "telegram")
+ }
answer.Payload = disco
} else if dt == discoTypeItems {
disco := answer.DiscoItems()