diff options
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/telegram/utils.go b/telegram/utils.go index c12321d..a281a90 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -301,6 +301,17 @@ func (c *Client) SendMUCStatuses(chatID int64) { Filter: &client.ChatMembersFilterMembers{}, }) if err == nil { + chatIDString := strconv.FormatInt(chatID, 10) + + myNickname := "me" + if c.me != nil { + myNickname := c.me.FirstName + if c.me.LastName != "" { + myNickname = myNickname + " " + c.me.LastName + } + } + myAffiliation := "member" + for _, member := range members.Members { var senderId int64 switch member.MemberId.MessageSenderType() { @@ -311,15 +322,35 @@ func (c *Client) SendMUCStatuses(chatID int64) { memberChat, _ := member.MemberId.(*client.MessageSenderChat) senderId = memberChat.ChatId } + + nickname := c.formatContact(senderId) + affiliation := c.memberStatusToAffiliation(member.Status) + if c.me != nil && senderId == c.me.Id { + myNickname = nickname + myAffiliation = affiliation + continue + } + gateway.SendPresence( c.xmpp, c.jid, - gateway.SPFrom(strconv.FormatInt(chatID, 10)), - gateway.SPResource(c.formatContact(senderId)), + gateway.SPFrom(chatIDString), + gateway.SPResource(nickname), gateway.SPImmed(true), - gateway.SPAffiliation(c.memberStatusToAffiliation(member.Status)), + gateway.SPAffiliation(affiliation), ) } + + // according to the spec, own member entry should be sent the last + gateway.SendPresence( + c.xmpp, + c.jid, + gateway.SPFrom(chatIDString), + gateway.SPResource(myNickname), + gateway.SPImmed(true), + gateway.SPAffiliation(myAffiliation), + gateway.SPMUCStatusCodes([]uint16{110, 210}), + ) } } |