mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-05-19 20:33:45 +02:00
Compare commits
5 commits
072847512d
...
6f56ff7260
Author | SHA1 | Date | |
---|---|---|---|
Timo Ley | 6f56ff7260 | ||
bcdfa04c57 | |||
fee357b652 | |||
46420c1319 | |||
d1bc6871d0 |
|
@ -54,10 +54,10 @@ const (
|
||||||
`
|
`
|
||||||
updateUserQuery = `
|
updateUserQuery = `
|
||||||
UPDATE "user"
|
UPDATE "user"
|
||||||
SET username=$1, agent=$2, device=$3,
|
SET username=$2, agent=$3, device=$4,
|
||||||
management_room=$4, space_room=$5,
|
management_room=$5, space_room=$6,
|
||||||
phone_last_seen=$6, phone_last_pinged=$7, timezone=$8
|
phone_last_seen=$7, phone_last_pinged=$8, timezone=$9
|
||||||
WHERE mxid=$9
|
WHERE mxid=$1
|
||||||
`
|
`
|
||||||
getUserLastAppStateKeyIDQuery = "SELECT key_id FROM whatsmeow_app_state_sync_keys WHERE jid=$1 ORDER BY timestamp DESC LIMIT 1"
|
getUserLastAppStateKeyIDQuery = "SELECT key_id FROM whatsmeow_app_state_sync_keys WHERE jid=$1 ORDER BY timestamp DESC LIMIT 1"
|
||||||
)
|
)
|
||||||
|
@ -126,9 +126,9 @@ func (user *User) sqlVariables() []any {
|
||||||
device = dbutil.NumPtr(user.JID.Device)
|
device = dbutil.NumPtr(user.JID.Device)
|
||||||
}
|
}
|
||||||
return []any{
|
return []any{
|
||||||
username, agent, device, user.ManagementRoom, user.SpaceRoom,
|
user.MXID, username, agent, device, user.ManagementRoom, user.SpaceRoom,
|
||||||
dbutil.UnixPtr(user.PhoneLastSeen), dbutil.UnixPtr(user.PhoneLastPinged),
|
dbutil.UnixPtr(user.PhoneLastSeen), dbutil.UnixPtr(user.PhoneLastPinged),
|
||||||
user.Timezone, user.MXID,
|
user.Timezone,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -526,6 +526,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
Msg("Storing history sync")
|
Msg("Storing history sync")
|
||||||
|
|
||||||
successfullySavedTotal := 0
|
successfullySavedTotal := 0
|
||||||
|
failedToSaveTotal := 0
|
||||||
totalMessageCount := 0
|
totalMessageCount := 0
|
||||||
for _, conv := range evt.GetConversations() {
|
for _, conv := range evt.GetConversations() {
|
||||||
jid, err := types.ParseJID(conv.GetId())
|
jid, err := types.ParseJID(conv.GetId())
|
||||||
|
@ -578,6 +579,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
var minTimeIndex, maxTimeIndex int
|
var minTimeIndex, maxTimeIndex int
|
||||||
|
|
||||||
successfullySaved := 0
|
successfullySaved := 0
|
||||||
|
failedToSave := 0
|
||||||
unsupportedTypes := 0
|
unsupportedTypes := 0
|
||||||
for i, rawMsg := range conv.GetMessages() {
|
for i, rawMsg := range conv.GetMessages() {
|
||||||
// Don't store messages that will just be skipped.
|
// Don't store messages that will just be skipped.
|
||||||
|
@ -614,6 +616,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
Str("msg_id", msgEvt.Info.ID).
|
Str("msg_id", msgEvt.Info.ID).
|
||||||
Time("msg_time", msgEvt.Info.Timestamp).
|
Time("msg_time", msgEvt.Info.Timestamp).
|
||||||
Msg("Failed to save historical message")
|
Msg("Failed to save historical message")
|
||||||
|
failedToSave++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = message.Insert(ctx)
|
err = message.Insert(ctx)
|
||||||
|
@ -623,12 +626,16 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
Str("msg_id", msgEvt.Info.ID).
|
Str("msg_id", msgEvt.Info.ID).
|
||||||
Time("msg_time", msgEvt.Info.Timestamp).
|
Time("msg_time", msgEvt.Info.Timestamp).
|
||||||
Msg("Failed to save historical message")
|
Msg("Failed to save historical message")
|
||||||
|
failedToSave++
|
||||||
|
} else {
|
||||||
|
successfullySaved++
|
||||||
}
|
}
|
||||||
successfullySaved++
|
|
||||||
}
|
}
|
||||||
successfullySavedTotal += successfullySaved
|
successfullySavedTotal += successfullySaved
|
||||||
|
failedToSaveTotal += failedToSave
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Int("saved_count", successfullySaved).
|
Int("saved_count", successfullySaved).
|
||||||
|
Int("failed_count", failedToSave).
|
||||||
Int("unsupported_msg_type_count", unsupportedTypes).
|
Int("unsupported_msg_type_count", unsupportedTypes).
|
||||||
Time("lowest_time", minTime).
|
Time("lowest_time", minTime).
|
||||||
Int("lowest_time_index", minTimeIndex).
|
Int("lowest_time_index", minTimeIndex).
|
||||||
|
@ -646,6 +653,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
}
|
}
|
||||||
log.Info().
|
log.Info().
|
||||||
Int("total_saved_count", successfullySavedTotal).
|
Int("total_saved_count", successfullySavedTotal).
|
||||||
|
Int("total_failed_count", failedToSaveTotal).
|
||||||
Int("total_message_count", totalMessageCount).
|
Int("total_message_count", totalMessageCount).
|
||||||
Msg("Finished storing history sync")
|
Msg("Finished storing history sync")
|
||||||
|
|
||||||
|
|
|
@ -1814,6 +1814,7 @@ func (portal *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent {
|
||||||
InvitePtr: &invite,
|
InvitePtr: &invite,
|
||||||
Users: map[id.UserID]int{
|
Users: map[id.UserID]int{
|
||||||
portal.MainIntent().UserID: 100,
|
portal.MainIntent().UserID: 100,
|
||||||
|
portal.bridge.Bot.UserID: 100,
|
||||||
},
|
},
|
||||||
Events: map[string]int{
|
Events: map[string]int{
|
||||||
event.StateRoomName.Type: anyone,
|
event.StateRoomName.Type: anyone,
|
||||||
|
@ -1831,6 +1832,9 @@ func (portal *Portal) applyPowerLevelFixes(levels *event.PowerLevelsEventContent
|
||||||
changed = levels.EnsureEventLevel(event.EventReaction, 0) || changed
|
changed = levels.EnsureEventLevel(event.EventReaction, 0) || changed
|
||||||
changed = levels.EnsureEventLevel(event.EventRedaction, 0) || changed
|
changed = levels.EnsureEventLevel(event.EventRedaction, 0) || changed
|
||||||
changed = levels.EnsureEventLevel(TypeMSC3381PollResponse, 0) || changed
|
changed = levels.EnsureEventLevel(TypeMSC3381PollResponse, 0) || changed
|
||||||
|
if portal.IsPrivateChat() {
|
||||||
|
changed = levels.EnsureUserLevel(portal.bridge.Bot.UserID, 100) || changed
|
||||||
|
}
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue