Fix linter, debug logs, error handling

This commit is contained in:
Till Faelligen 2022-11-07 09:00:50 +01:00
parent e75a0d8ee2
commit dc275427b5
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -222,7 +222,7 @@ func (s *OutputRoomEventConsumer) copyPushrules(ctx context.Context, oldRoomID s
if err != nil { if err != nil {
return err return err
} }
if err := s.db.SaveAccountData(ctx, membership.Localpart, "", "m.push_rules", rules); err != nil { if err = s.db.SaveAccountData(ctx, membership.Localpart, "", "m.push_rules", rules); err != nil {
return fmt.Errorf("failed to update pushrules: %w", err) return fmt.Errorf("failed to update pushrules: %w", err)
} }
} }
@ -255,7 +255,8 @@ func (s *OutputRoomEventConsumer) updateMDirect(ctx context.Context, oldRoomID,
} }
// Only hit the database if we found the old room as a DM for this user // Only hit the database if we found the old room as a DM for this user
if found { if found {
data, err := json.Marshal(newDirectChats) var data []byte
data, err = json.Marshal(newDirectChats)
if err != nil { if err != nil {
return true return true
} }
@ -294,8 +295,10 @@ func (s *OutputRoomEventConsumer) processMessage(ctx context.Context, event *gom
// Handle room upgrades // Handle room upgrades
oldRoomID := event.RoomID() oldRoomID := event.RoomID()
newRoomID := gjson.GetBytes(event.Content(), "replacement_room").Str newRoomID := gjson.GetBytes(event.Content(), "replacement_room").Str
log.Debugf("XXX: received tombstone event: %s -> %s", oldRoomID, newRoomID) if err = s.handleRoomUpgrade(ctx, oldRoomID, newRoomID, members, roomSize); err != nil {
s.handleRoomUpgrade(ctx, oldRoomID, newRoomID, members, roomSize) // while inconvenient, this shouldn't stop us from sending push notifications
log.WithError(err).Errorf("UserAPI: failed to handle room upgrade for users")
}
} }