Ensure settings map is always initialized

Without this, if settings are not found in account data (`M_NOT_FOUND`),
we won't initialize the map and we'll panic later:

> assignment to entry in nil map

Breaking settings for all new rooms is definitely not what we inteded.

Likely a regression since 726bc95c26, but related to fcac0a202d as
well.
This commit is contained in:
Slavi Pantaleev
2022-08-24 12:21:11 +03:00
parent ef22ca03d9
commit ed5ff6456a

View File

@@ -161,7 +161,7 @@ func (b *Bot) getSettings(ctx context.Context, roomID id.RoomID) (settings, erro
span := sentry.StartSpan(ctx, "http.server", sentry.TransactionName("getSettings"))
defer span.Finish()
var config settings
config := settings{}
err := b.lp.GetClient().GetRoomAccountData(roomID, settingskey, &config)
if err != nil {
if strings.Contains(err.Error(), "M_NOT_FOUND") {