mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 12:17:06 +00:00
Allow listing MUC owners
This commit is contained in:
parent
a01e864d71
commit
4b2ae50f67
2 changed files with 47 additions and 5 deletions
|
|
@ -91,6 +91,7 @@ const (
|
||||||
MembersListBanned
|
MembersListBanned
|
||||||
MembersListBannedAndAdministrators
|
MembersListBannedAndAdministrators
|
||||||
MembersListAdministrators
|
MembersListAdministrators
|
||||||
|
MembersListCreators
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -221,6 +222,18 @@ func (c *Client) GetContactByID(id int64, chat *client.Chat) (*client.Chat, *cli
|
||||||
return chat, user, nil
|
return chat, user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetChatByID gets exactly a chat from a cache, or error if chat is not found
|
||||||
|
func (c *Client) GetChatByID(id int64, chat *client.Chat) (*client.Chat, error) {
|
||||||
|
chat, _, err := c.GetContactByID(id, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if chat == nil {
|
||||||
|
return nil, errors.New("Chat not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return chat, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetChatType obtains chat type from its information
|
// GetChatType obtains chat type from its information
|
||||||
func (c *Client) GetChatType(id int64) (ChatType, *client.Chat, error) {
|
func (c *Client) GetChatType(id int64) (ChatType, *client.Chat, error) {
|
||||||
if !c.Online() || id == 0 {
|
if !c.Online() || id == 0 {
|
||||||
|
|
@ -2620,6 +2633,38 @@ func (c *Client) sendMessagesReverse(chatID int64, messages []*client.Message, p
|
||||||
|
|
||||||
// GetChatMembers retrieves a list of chat members. "Limited" mode works only if there are no more than 20 members at all
|
// GetChatMembers retrieves a list of chat members. "Limited" mode works only if there are no more than 20 members at all
|
||||||
func (c *Client) GetChatMembers(chatID int64, limited bool, query string, membersList MembersList) ([]*client.ChatMember, error) {
|
func (c *Client) GetChatMembers(chatID int64, limited bool, query string, membersList MembersList) ([]*client.ChatMember, error) {
|
||||||
|
if membersList == MembersListCreators {
|
||||||
|
chat, err := c.GetChatByID(chatID, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
chatType := chat.Type.ChatTypeType()
|
||||||
|
if chatType == client.TypeChatTypeBasicGroup {
|
||||||
|
basicGroupType, _ := chat.Type.(*client.ChatTypeBasicGroup)
|
||||||
|
fullInfo, err := c.client.GetBasicGroupFullInfo(&client.GetBasicGroupFullInfoRequest{
|
||||||
|
BasicGroupId: basicGroupType.BasicGroupId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if fullInfo.CreatorUserId != 0 {
|
||||||
|
chatMember, err := c.client.GetChatMember(&client.GetChatMemberRequest{
|
||||||
|
ChatId: chatID,
|
||||||
|
MemberId: &client.MessageSenderUser{UserId: fullInfo.CreatorUserId},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return []*client.ChatMember{chatMember}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("Creator not found")
|
||||||
|
}
|
||||||
|
|
||||||
var filters []client.ChatMembersFilter
|
var filters []client.ChatMembersFilter
|
||||||
switch membersList {
|
switch membersList {
|
||||||
case MembersListMembers:
|
case MembersListMembers:
|
||||||
|
|
@ -2638,11 +2683,9 @@ func (c *Client) GetChatMembers(chatID int64, limited bool, query string, member
|
||||||
if limited {
|
if limited {
|
||||||
limit = 20
|
limit = 20
|
||||||
|
|
||||||
chat, _, err := c.GetContactByID(chatID, nil)
|
chat, err := c.GetChatByID(chatID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if chat == nil {
|
|
||||||
return nil, errors.New("Chat not found")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chatType := chat.Type.ChatTypeType()
|
chatType := chat.Type.ChatTypeType()
|
||||||
|
|
|
||||||
|
|
@ -1233,8 +1233,7 @@ func handleGetQueryMucAdmin(s xmpp.Sender, iq *stanza.IQ, query *extensions.Quer
|
||||||
}
|
}
|
||||||
switch item.Affiliation {
|
switch item.Affiliation {
|
||||||
case "owner":
|
case "owner":
|
||||||
iqAnswerSetError(answer, 403)
|
membersList = telegram.MembersListCreators
|
||||||
return
|
|
||||||
case "admin":
|
case "admin":
|
||||||
membersList = telegram.MembersListAdministrators
|
membersList = telegram.MembersListAdministrators
|
||||||
case "member":
|
case "member":
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue