From ec8d8ec45baa2d36f49dcc2b634337210aa1b495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 1 May 2023 10:56:05 -0400 Subject: [PATCH] fix: closes #11511 reset all user skins if they are no longer available --- .../3.1.0/reset_user_bootswatch_skin.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/upgrades/3.1.0/reset_user_bootswatch_skin.js diff --git a/src/upgrades/3.1.0/reset_user_bootswatch_skin.js b/src/upgrades/3.1.0/reset_user_bootswatch_skin.js new file mode 100644 index 0000000000..21d5569b39 --- /dev/null +++ b/src/upgrades/3.1.0/reset_user_bootswatch_skin.js @@ -0,0 +1,24 @@ +'use strict'; + + +const db = require('../../database'); + +module.exports = { + name: 'Reset old bootswatch skin for all users', + timestamp: Date.UTC(2023, 4, 1), + method: async function () { + const batch = require('../../batch'); + const css = require('../../meta/css'); + + batch.processSortedSet('users:joindate', async (uids) => { + let settings = await db.getObjects(uids.map(uid => `user:${uid}:settings`)); + settings = settings.filter( + s => s && s.bootswatchSkin && !css.supportedSkins.includes(s.bootswatchSkin) + ); + + await db.setObjectBulk(settings.map(s => ([`user:${s.uid}`, { bootswatchSkin: '' }]))); + }, { + batch: 500, + }); + }, +};