mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
Add MUC-to-legacy migrator
This commit is contained in:
parent
65cc9b1551
commit
d6582a888f
3 changed files with 30 additions and 4 deletions
|
|
@ -458,8 +458,13 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) (strin
|
|||
if err != nil {
|
||||
return err.Error(), false
|
||||
}
|
||||
if args[0] == "muc" && args[1] == "true" {
|
||||
go c.MigrateToMUCs()
|
||||
if args[0] == "muc" {
|
||||
switch args[1] {
|
||||
case "true":
|
||||
go c.MigrateToMUCs()
|
||||
case "false":
|
||||
go c.MigrateFromMUCs()
|
||||
}
|
||||
}
|
||||
gateway.DirtySessions = true
|
||||
|
||||
|
|
|
|||
|
|
@ -2817,6 +2817,22 @@ func (c *Client) MigrateToMUCs() {
|
|||
}
|
||||
}
|
||||
|
||||
// MigrateFromMUCs kicks from MUCs and subscribes back to legacy group chats
|
||||
func (c *Client) MigrateFromMUCs() {
|
||||
var chatIDs []int64
|
||||
for _, chat := range c.GetGroupChats() {
|
||||
chatIDs = append(chatIDs, chat.Id)
|
||||
}
|
||||
|
||||
c.locks.mucCacheLock.Lock()
|
||||
for _, chatID := range chatIDs {
|
||||
c.kickMeFromMUC(chatID, []uint16{110, 332}, false, nil)
|
||||
delete(c.mucCache, chatID)
|
||||
c.subscribeToID(chatID, nil, false)
|
||||
}
|
||||
c.locks.mucCacheLock.Unlock()
|
||||
}
|
||||
|
||||
// SetChatMemberStatus is a handy wrapper for the following TDLib method
|
||||
func (c *Client) SetChatMemberStatus(chatID, userID int64, status ChatMemberStatus, numericPayload int64, stringPayload, nickname string) error {
|
||||
var chatMemberStatus client.ChatMemberStatus
|
||||
|
|
|
|||
|
|
@ -1478,8 +1478,13 @@ func handleSetQueryCommand(s xmpp.Sender, iq *stanza.IQ, command *stanza.Command
|
|||
errString = fmt.Sprintf("Error for field %v: %v, aborting", field.Var, err.Error())
|
||||
break
|
||||
}
|
||||
if field.Var == "muc" && fieldValue == "true" {
|
||||
go session.MigrateToMUCs()
|
||||
if field.Var == "muc" {
|
||||
switch fieldValue {
|
||||
case "true":
|
||||
go session.MigrateToMUCs()
|
||||
case "false":
|
||||
go session.MigrateFromMUCs()
|
||||
}
|
||||
}
|
||||
infoStrings = append(infoStrings, fmt.Sprintf("%s set to %s", field.Var, value))
|
||||
gateway.DirtySessions = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue