-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve roles persistency #40
base: master
Are you sure you want to change the base?
Conversation
* Do not cache roles at start: persistency store might not be available yet and an empty response can be returned * Save roles back to the brain on change, except `admin`
623ce89
to
340b371
Compare
@ceci-woodward this should in principle provide a better solution to #36 and #37 than #38 and should also provide a fix to the issue described in my comment, if I am not overlooking anything... |
My changes in this PR shouldn't be merged due to it breaking backwards compatability. |
What exactly does this break? Applying this patch actually makes hubot-auth work. The fact that if you restart hubot all roles are lost/forgotten is a pretty big issue... |
Can we merge this and release a new semver major version? |
@alFReD-NSH I forked this a whole ago with the changes the changes above so it actually works. I'm not sure how this plugin is meant to be useful in the slightest without the ability to retain the roles information after a reboot, but here it is |
@JSzaszvari @dberzano @alFReD-NSH I recall the breaking change was due to us moving the location redis would store the users roles. I'm guessing its a race condition where there are times that the Adding the role and verifying it exists After a restart verifying the role still exists After pulling in @dberzano change Overall I like the change, but we should probably try and |
Something like the following should work for migrating roles from the old format. module.exports = (robot) ->
robot.brain.on 'connected', () ->
roles = robot.brain.get('roles')
for id, user of robot.brain.users()
if user.roles and user.roles.length
console.info "converting #{id} to the new roles format..."
roles[id] or= []
userRoles = roles[id]
userRoles.push role for role in user.roles when role not in userRoles
delete user.roles
roles = robot.brain.set('roles', roles)
# ... |
Improve roles handling and persistency
an empty response can be returned
admin