Fix the problem that the synchronization session is not consistent with the skype side

This commit is contained in:
zhaoYangguang 2020-09-22 19:43:34 +08:00
parent ab5d852629
commit 891ff890db
4 changed files with 24 additions and 8 deletions

View File

@ -484,7 +484,7 @@ func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
ce.Reply("Failed to contacts chat list (see logs for details)") ce.Reply("Failed to contacts chat list (see logs for details)")
} }
ce.Reply("Syncing conversations...") ce.Reply("Syncing conversations...")
err = ce.User.Conn.GetConversations("") err = ce.User.Conn.GetConversations("", user.bridge.Config.Bridge.InitialChatSync)
if err != nil { if err != nil {
user.log.Errorln("Error get conversations:", err) user.log.Errorln("Error get conversations:", err)
ce.Reply("Failed to conversations list (see logs for details)") ce.Reply("Failed to conversations list (see logs for details)")
@ -625,7 +625,7 @@ func (handler *CommandHandler) CommandList(ce *CommandEvent) {
return return
} }
} else { } else {
err = ce.User.Conn.GetConversations("") err = ce.User.Conn.GetConversations("", handler.bridge.Config.Bridge.InitialChatSync)
if err != nil { if err != nil {
ce.Reply("Get conversations error") ce.Reply("Get conversations error")
return return
@ -669,7 +669,7 @@ func (handler *CommandHandler) CommandOpen(ce *CommandEvent) {
ce.Reply("That looks like a user ID. Did you mean `pm %s`?", jid[:len(jid)-len(whatsappExt.NewUserSuffix)]) ce.Reply("That looks like a user ID. Did you mean `pm %s`?", jid[:len(jid)-len(whatsappExt.NewUserSuffix)])
return return
} }
ce.User.Conn.GetConversations("") ce.User.Conn.GetConversations("", handler.bridge.Config.Bridge.InitialChatSync)
fmt.Println("user.Conn.Store.Chats: ", user.Conn.Store.Chats) fmt.Println("user.Conn.Store.Chats: ", user.Conn.Store.Chats)
chat, ok := user.Conn.Store.Chats[jid] chat, ok := user.Conn.Store.Chats[jid]
if !ok { if !ok {
@ -923,7 +923,7 @@ func (handler *CommandHandler) CommandInvite(ce *CommandEvent) {
fmt.Println("user.Conn.Store.Chats", user.Conn.Store.Contacts) fmt.Println("user.Conn.Store.Chats", user.Conn.Store.Contacts)
if !ok { if !ok {
//user.Conn //user.Conn
err := ce.User.Conn.GetConversations("") err := ce.User.Conn.GetConversations("", handler.bridge.Config.Bridge.InitialChatSync)
//time.Sleep(5 * time.Second) //time.Sleep(5 * time.Second)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)

View File

@ -105,6 +105,8 @@ bridge:
end: true end: true
# Number of chats to sync for new users. # Number of chats to sync for new users.
# Since some of the obtained conversations are not the conversations that the user needs to see,
# the actual number of conversations displayed on the matrix client will be slightly less than the set value
initial_chat_sync_count: 10 initial_chat_sync_count: 10
# Number of old messages to fill when creating new portal rooms. # Number of old messages to fill when creating new portal rooms.
initial_history_fill_count: 20 initial_history_fill_count: 20

View File

@ -620,6 +620,10 @@ func (portal *Portal) SyncSkype(user *User, chat skype.Conversation) {
} else { } else {
fmt.Println("SyncSkype ensureUserInvited", portal.MXID) fmt.Println("SyncSkype ensureUserInvited", portal.MXID)
portal.ensureUserInvited(user) portal.ensureUserInvited(user)
rep, err := portal.MainIntent().SetPowerLevel(portal.MXID, user.MXID, 100)
if err != nil {
portal.log.Warnfln("SyncSkype: SetPowerLevel err: ", err, rep)
}
} }
if portal.IsPrivateChat() { if portal.IsPrivateChat() {
@ -680,7 +684,7 @@ func (portal *Portal) SyncSkype(user *User, chat skype.Conversation) {
func (portal *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent { func (portal *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent {
anyone := 0 anyone := 0
nope := 99 nope := 99
invite := 99 invite := 50
if portal.bridge.Config.Bridge.AllowUserInvite { if portal.bridge.Config.Bridge.AllowUserInvite {
invite = 0 invite = 0
} }

16
user.go
View File

@ -399,7 +399,7 @@ func (user *User) Login(ce *CommandEvent, name string, password string) {
user.JID = "8:" + user.Conn.UserProfile.Username + skypeExt.NewUserSuffix user.JID = "8:" + user.Conn.UserProfile.Username + skypeExt.NewUserSuffix
user.addToJIDMap() user.addToJIDMap()
//user.PostLogin() //user.PostLogin()
ce.User.Conn.GetConversations("") ce.User.Conn.GetConversations("", user.bridge.Config.Bridge.InitialChatSync)
} }
func loopPresence(user *User) { func loopPresence(user *User) {
Loop: Loop:
@ -571,8 +571,18 @@ func (user *User) syncPortals(chatMap map[string]skype.Conversation, createAll b
if chat.Properties.ConversationStatus != "Accepted" && len(chat.ThreadProperties.Lastjoinat) < 1 { if chat.Properties.ConversationStatus != "Accepted" && len(chat.ThreadProperties.Lastjoinat) < 1 {
continue continue
} }
// user.log.Warnfln("Non-integer last message time in %s: %s", chat.Id, t) }
//continue // Filter calllogs conversation
if chat.Id == "48:calllogs" {
continue
}
// Filter conversations that have not sent messages
if chat.LastMessage.Id == "" {
continue
}
// 'Lastleaveat' value means that you have left the current conversation
if len(chat.ThreadProperties.Lastleaveat) > 0 {
continue
} }
ts := uint64(t.UnixNano()) ts := uint64(t.UnixNano())
cid, _ := chat.Id.(string) cid, _ := chat.Id.(string)