mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
Send service messages to connected full JIDs rather than one bare JID wherever possible
This commit is contained in:
parent
f875e679da
commit
9ee13bf582
4 changed files with 19 additions and 11 deletions
|
|
@ -276,7 +276,7 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) {
|
|||
if isMUC {
|
||||
_, jids = c.getMUCJoinedJIDs(update.ChatId, nil, true)
|
||||
} else {
|
||||
jids = c.getCarbonFullJids(true, ignoredResource)
|
||||
jids = c.GetCarbonFullJids(true, ignoredResource, true)
|
||||
}
|
||||
if len(jids) == 0 {
|
||||
log.Info("The only resource is ignored, aborting")
|
||||
|
|
@ -419,7 +419,7 @@ func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) {
|
|||
}
|
||||
} else {
|
||||
fromJid = gateway.CHATNODE(update.ChatId)
|
||||
jids = c.getCarbonFullJids(true, "")
|
||||
jids = c.GetCarbonFullJids(true, "", false)
|
||||
for _, jid := range jids {
|
||||
gateway.SendTextMessage(jid, fromJid, text, c.xmpp, isGroupchat)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,9 @@ func (c *Client) wizardStageOrPrompt(stage LoginStage, message string) {
|
|||
if c.loginWizard == nil {
|
||||
c.locks.loginWizardWriteLock.Unlock()
|
||||
if message != "" {
|
||||
gateway.SendServiceMessage(c.jid, message, c.xmpp)
|
||||
for _, jid := range c.GetCarbonFullJids(true, "", false) {
|
||||
gateway.SendServiceMessage(jid, message, c.xmpp)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !c.loginWizard.chanBusy {
|
||||
|
|
|
|||
|
|
@ -1743,8 +1743,8 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
|
|||
addMembers, _ := message.Content.(*client.MessageChatAddMembers)
|
||||
for _, memberId := range addMembers.MemberUserIds {
|
||||
if c.me != nil && c.me.Id == memberId {
|
||||
for resource := range c.resourcesRange() {
|
||||
gateway.InviteToMUC(chatId, c.jid+"/"+resource, c.xmpp)
|
||||
for _, jid := range c.GetCarbonFullJids(true, "", false) {
|
||||
gateway.InviteToMUC(chatId, jid, c.xmpp)
|
||||
}
|
||||
}
|
||||
c.mucOccupantRolePresence(chatId, memberId, ChatMemberStatusUnmuted, c.GetMUCNickname(memberId))
|
||||
|
|
@ -1753,8 +1753,8 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
|
|||
deleteMember, _ := message.Content.(*client.MessageChatDeleteMember)
|
||||
c.mucOccupantRolePresence(chatId, deleteMember.UserId, ChatMemberStatusKicked, c.GetMUCNickname(deleteMember.UserId))
|
||||
case client.TypeMessageBasicGroupChatCreate, client.TypeMessageSupergroupChatCreate:
|
||||
for resource := range c.resourcesRange() {
|
||||
gateway.InviteToMUC(chatId, c.jid+"/"+resource, c.xmpp)
|
||||
for _, jid := range c.GetCarbonFullJids(true, "", false) {
|
||||
gateway.InviteToMUC(chatId, jid, c.xmpp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1795,7 +1795,7 @@ func (c *Client) SendMessageToGateway(chatId int64, message *client.Message, id
|
|||
var originalFrom string
|
||||
if len(groupChatTos) == 0 {
|
||||
isCarbon = c.isCarbonsEnabled() && message.IsOutgoing
|
||||
jids = c.getCarbonFullJids(isCarbon, "")
|
||||
jids = c.GetCarbonFullJids(isCarbon, "", true)
|
||||
} else {
|
||||
isGroupchat = true
|
||||
jids = groupChatTos
|
||||
|
|
@ -2555,7 +2555,8 @@ func (c *Client) getFromOutbox(xmppId string) string {
|
|||
return resource
|
||||
}
|
||||
|
||||
func (c *Client) getCarbonFullJids(isOutgoing bool, ignoredResource string) []string {
|
||||
// GetCarbonFullJids builds a set of full jids or of one bare jid for outgoing stanzas
|
||||
func (c *Client) GetCarbonFullJids(isOutgoing bool, ignoredResource string, forceFull bool) []string {
|
||||
var jids []string
|
||||
if isOutgoing {
|
||||
for resource := range c.resourcesRange() {
|
||||
|
|
@ -2563,6 +2564,9 @@ func (c *Client) getCarbonFullJids(isOutgoing bool, ignoredResource string) []st
|
|||
jids = append(jids, c.jid+"/"+resource)
|
||||
}
|
||||
}
|
||||
if len(jids) == 0 && !forceFull {
|
||||
jids = []string{c.jid}
|
||||
}
|
||||
} else {
|
||||
jids = []string{c.jid}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,9 +402,11 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
|
|||
|
||||
if msg.XMLName.Space == "jabber:component:accept" && msg.Error.Code == 401 {
|
||||
suffix := "@" + msg.From
|
||||
for bare := range sessions {
|
||||
for bare, session := range sessions {
|
||||
if strings.HasSuffix(bare, suffix) {
|
||||
gateway.SendServiceMessage(bare, "Your server \""+msg.From+"\" does not allow to send carbons", component)
|
||||
for _, jid := range session.GetCarbonFullJids(true, "", false) {
|
||||
gateway.SendServiceMessage(jid, "Your server \""+msg.From+"\" does not allow to send carbons", component)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue