mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
groups: possible solution to 8a1aae3 (fixes groups permissioning)
This commit is contained in:
parent
ad2b37fe50
commit
89c6192e28
2 changed files with 48 additions and 55 deletions
|
|
@ -30,20 +30,19 @@ algos = require 'habitrpg-shared/script/algos'
|
|||
setupSubscriptions = (page, model, params, next, cb) ->
|
||||
uuid = model.get('_userId') or model.session.userId # see http://goo.gl/TPYIt
|
||||
selfQ = model.query('users').withId(uuid) #keep this for later
|
||||
groupsQ = model.query('groups').withMember(uuid)
|
||||
|
||||
# Fetch public groups as _publicGroups - not it has to come at very end due to racer bug
|
||||
# Fetch public groups as _publicGroups
|
||||
# Note: due to https://github.com/codeparty/racer/issues/57, this has to come at the very beginning. The more limited
|
||||
# the returned fields in motifs, the sooner they must come in fetch / subscribes.
|
||||
model.query('groups').publicGroups().fetch (err, pg) ->
|
||||
return next(err) if err
|
||||
model.set '_publicGroups', _.sortBy(pg.get(), (g) -> -_.size(g.members))
|
||||
|
||||
groupsQ.fetch (err, groups) ->
|
||||
model.query('groups').withMember(uuid).fetch (err, groups) ->
|
||||
return next(err) if err
|
||||
finished = (descriptors, paths) ->
|
||||
# Add public "Tavern" guild in
|
||||
descriptors.push('groups.habitrpg'); paths.push('_habitRPG')
|
||||
# descriptors.unshift model.query('groups').publicGroups()
|
||||
# paths.unshift('_publicGroups')
|
||||
|
||||
# Subscribe to each descriptor
|
||||
model.subscribe.apply model, descriptors.concat ->
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ groupSystem = (store) ->
|
|||
Find group which has member by id
|
||||
###
|
||||
store.query.expose "groups", "withMember", (id, type) ->
|
||||
q = @where('members').contains([id])#.only(['id','members','type'])
|
||||
q = @where('members').contains([id]).only(['id', 'type', 'name', 'description', 'members' , 'privacy'])
|
||||
q = q.where('type').equals(type) if type?
|
||||
store.queryAccess 'groups', 'withMember', publicAccess
|
||||
|
||||
|
|
@ -140,13 +140,7 @@ groupSystem = (store) ->
|
|||
store.query.expose "groups", "publicGroups", ->
|
||||
@where('privacy').equals('public')
|
||||
.where('type').equals('guild')
|
||||
# .only [
|
||||
# 'name'
|
||||
# 'description'
|
||||
# 'users'
|
||||
# 'members'
|
||||
# 'privacy'
|
||||
# ]
|
||||
.only(['id', 'type', 'name', 'description', 'members' , 'privacy'])
|
||||
store.queryAccess "groups", "publicGroups", publicAccess
|
||||
|
||||
###
|
||||
|
|
|
|||
Loading…
Reference in a new issue