|
@@ -1072,13 +1072,14 @@ const cmdSyncHelp = `sync <appstate/contacts/groups> [--create-portals] - Synchr
|
|
|
|
|
|
func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
|
|
|
if len(ce.Args) == 0 {
|
|
|
- ce.Reply("**Usage:** `sync <appstate/contacts/groups> [--create-portals]`")
|
|
|
+ ce.Reply("**Usage:** `sync <appstate/contacts/groups/space> [--create-portals]`")
|
|
|
return
|
|
|
}
|
|
|
args := strings.ToLower(strings.Join(ce.Args, " "))
|
|
|
contacts := strings.Contains(args, "contacts")
|
|
|
appState := strings.Contains(args, "appstate")
|
|
|
- groups := strings.Contains(args, "groups")
|
|
|
+ space := strings.Contains(args, "space")
|
|
|
+ groups := strings.Contains(args, "groups") || space
|
|
|
createPortals := strings.Contains(args, "--create-portals")
|
|
|
|
|
|
if appState {
|
|
@@ -1100,6 +1101,20 @@ func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
|
|
|
ce.Reply("Resynced contacts")
|
|
|
}
|
|
|
}
|
|
|
+ if space {
|
|
|
+ keys := ce.Bridge.DB.Portal.FindPrivateChatsNotInSpace(ce.User.JID)
|
|
|
+ count := 0
|
|
|
+ for _, key := range keys {
|
|
|
+ portal := ce.Bridge.GetPortalByJID(key)
|
|
|
+ portal.addToSpace(ce.User)
|
|
|
+ count++
|
|
|
+ }
|
|
|
+ plural := "s"
|
|
|
+ if count == 1 {
|
|
|
+ plural = ""
|
|
|
+ }
|
|
|
+ ce.Reply("Added %d DM room%s to space", count, plural)
|
|
|
+ }
|
|
|
if groups {
|
|
|
err := ce.User.ResyncGroups(createPortals)
|
|
|
if err != nil {
|