Reset all User avatars (redis)
-
Simple. Something that lets you reset the avatar for each user. To anything. Could be a specified image. Or could just be a palceholder image.
I came across this issue when I migrated data from a Mybb install to Nodebb. Everything went well with the transfer. It's just that all the images are corrupt/dont exist anymore. And I don't want to even bother with moving over the gigabytes of images.
Suggestions for doing this without a plugin is much appreciated.
Nodebb is currently running off Redis (Something I have very little experience with the cli) -
@mikemaddem ok here's a bash script that should reset all user avatars for redis:
redis-cli -n 0 --raw zrange "users:joindate" 0 -1 > uids.txt sed -i 's/^/hset "user:/' uids.txt && sed -i 's/$/" picture ""/' uids.txt cp uids.txt uids2.txt sed -i 's/picture/uploadedpicture/' uids.txt cat uids2.txt >> uids.txt echo "multi" > uids2.txt cat uids.txt >> uids2.txt echo "exec" >> uids2.txt redis-cli < uids2.txt
Make sure you back up your redis database before running that just in case.
-
@mikemaddem ah darn, just noticed you're using Redis. If you were using Mongo you could do this in the mongo shell:
> db.objects.update({ _key: { $regex: /^user:[0-9]+$/ } }, { $set: { picture: '', uploadedpicture: '' } }, { multi: true })
I'll look into how to do this in redis
-
yeah.... Mongo wasn't being nice to me when I was setting it up. And redis was super easy somehow.
If I could go back in time I'd try to fix mongo because Redis eats as much ram as Google Chrome on my pc.
Thanks mate! -
@mikemaddem ok here's a bash script that should reset all user avatars for redis:
redis-cli -n 0 --raw zrange "users:joindate" 0 -1 > uids.txt sed -i 's/^/hset "user:/' uids.txt && sed -i 's/$/" picture ""/' uids.txt cp uids.txt uids2.txt sed -i 's/picture/uploadedpicture/' uids.txt cat uids2.txt >> uids.txt echo "multi" > uids2.txt cat uids.txt >> uids2.txt echo "exec" >> uids2.txt redis-cli < uids2.txt
Make sure you back up your redis database before running that just in case.
-
CHEERS MATE!
I WISH I HAD SEEN THIS EARLIER.
BUT YES. IT WORKED. YOU FIXED IT. I LOVE YOU.
THANK YOU SOOOOO MUCH @PitaJ
I appreciate the help bud!