Make initial chat sync count configurable
This commit is contained in:
parent
498f210e10
commit
7981a11bd9
5 changed files with 10 additions and 4 deletions
|
@ -37,6 +37,7 @@ type BridgeConfig struct {
|
||||||
PortalMessageBuffer int `yaml:"portal_message_buffer"`
|
PortalMessageBuffer int `yaml:"portal_message_buffer"`
|
||||||
|
|
||||||
SyncDirectChatList bool `yaml:"sync_direct_chat_list"`
|
SyncDirectChatList bool `yaml:"sync_direct_chat_list"`
|
||||||
|
InitialChatSyncCount int `yaml:"initial_chat_sync_count"`
|
||||||
|
|
||||||
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
|
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
|
||||||
DoublePuppetAllowDiscovery bool `yaml:"double_puppet_allow_discovery"`
|
DoublePuppetAllowDiscovery bool `yaml:"double_puppet_allow_discovery"`
|
||||||
|
|
|
@ -43,6 +43,7 @@ func DoUpgrade(helper *up.Helper) {
|
||||||
helper.Copy(up.Bool, "bridge", "message_error_notices")
|
helper.Copy(up.Bool, "bridge", "message_error_notices")
|
||||||
helper.Copy(up.Int, "bridge", "portal_message_buffer")
|
helper.Copy(up.Int, "bridge", "portal_message_buffer")
|
||||||
helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
|
helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
|
||||||
|
helper.Copy(up.Int, "bridge", "initial_chat_sync_count")
|
||||||
helper.Copy(up.Map, "bridge", "double_puppet_server_map")
|
helper.Copy(up.Map, "bridge", "double_puppet_server_map")
|
||||||
helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery")
|
helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery")
|
||||||
helper.Copy(up.Map, "bridge", "login_shared_secret_map")
|
helper.Copy(up.Map, "bridge", "login_shared_secret_map")
|
||||||
|
|
|
@ -124,6 +124,8 @@ bridge:
|
||||||
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
|
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
|
||||||
# and is therefore prone to race conditions.
|
# and is therefore prone to race conditions.
|
||||||
sync_direct_chat_list: false
|
sync_direct_chat_list: false
|
||||||
|
# Number of chats to sync when connecting to Google Messages.
|
||||||
|
initial_chat_sync_count: 25
|
||||||
|
|
||||||
# Servers to always allow double puppeting from
|
# Servers to always allow double puppeting from
|
||||||
double_puppet_server_map:
|
double_puppet_server_map:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) ListConversations(count int64, folder gmproto.ListConversationsRequest_Folder) (*gmproto.ListConversationsResponse, error) {
|
func (c *Client) ListConversations(count int, folder gmproto.ListConversationsRequest_Folder) (*gmproto.ListConversationsResponse, error) {
|
||||||
msgType := gmproto.MessageType_BUGLE_MESSAGE
|
msgType := gmproto.MessageType_BUGLE_MESSAGE
|
||||||
if !c.conversationsFetchedOnce {
|
if !c.conversationsFetchedOnce {
|
||||||
msgType = gmproto.MessageType_BUGLE_ANNOTATION
|
msgType = gmproto.MessageType_BUGLE_ANNOTATION
|
||||||
|
@ -12,7 +12,7 @@ func (c *Client) ListConversations(count int64, folder gmproto.ListConversations
|
||||||
}
|
}
|
||||||
return typedResponse[*gmproto.ListConversationsResponse](c.sessionHandler.sendMessageWithParams(SendMessageParams{
|
return typedResponse[*gmproto.ListConversationsResponse](c.sessionHandler.sendMessageWithParams(SendMessageParams{
|
||||||
Action: gmproto.ActionType_LIST_CONVERSATIONS,
|
Action: gmproto.ActionType_LIST_CONVERSATIONS,
|
||||||
Data: &gmproto.ListConversationsRequest{Count: count, Folder: folder},
|
Data: &gmproto.ListConversationsRequest{Count: int64(count), Folder: folder},
|
||||||
MessageType: msgType,
|
MessageType: msgType,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
4
user.go
4
user.go
|
@ -654,11 +654,13 @@ func (user *User) aggressiveSetActive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) fetchAndSyncConversations() {
|
func (user *User) fetchAndSyncConversations() {
|
||||||
resp, err := user.Client.ListConversations(25, gmproto.ListConversationsRequest_INBOX)
|
user.zlog.Info().Msg("Fetching conversation list")
|
||||||
|
resp, err := user.Client.ListConversations(user.bridge.Config.Bridge.InitialChatSyncCount, gmproto.ListConversationsRequest_INBOX)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.zlog.Err(err).Msg("Failed to get conversation list")
|
user.zlog.Err(err).Msg("Failed to get conversation list")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
user.zlog.Info().Int("count", len(resp.GetConversations())).Msg("Syncing conversations")
|
||||||
for _, conv := range resp.GetConversations() {
|
for _, conv := range resp.GetConversations() {
|
||||||
user.syncConversation(conv)
|
user.syncConversation(conv)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue