Skip to content
Snippets Groups Projects
Commit a44c5d81 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

Post.authors work

parent ce343f79
No related branches found
No related tags found
No related merge requests found
...@@ -582,6 +582,7 @@ export async function getMetaGroupsFromCallbacks (user, selection){ ...@@ -582,6 +582,7 @@ export async function getMetaGroupsFromCallbacks (user, selection){
* @rights user * @rights user
*/ */
export async function getGroupsFromCallbacks(user, cbList){ export async function getGroupsFromCallbacks(user, cbList){
console.log(cbList);
let all_simple_groups = await getSimpleGroupsFromCallbacks(user, cbList); let all_simple_groups = await getSimpleGroupsFromCallbacks(user, cbList);
let all_meta_groups = await getMetaGroupsFromCallbacks(user, cbList); let all_meta_groups = await getMetaGroupsFromCallbacks(user, cbList);
return all_simple_groups.concat(all_meta_groups); return all_simple_groups.concat(all_meta_groups);
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
* @rights user * @rights user
*/ */
export async function visibleGroups(user){ export async function visibleGroups(user){
let group_ids = await user.ldap_access.listerGroupes(user.uid); let group_ids = await user.ldap_access.listGroups(user.uid);
return function (global_query_builder){ return function (global_query_builder){
if (typeof group_ids == "undefined") if (typeof group_ids == "undefined")
throw "invalid user"; throw "invalid user";
var membered_groups = qb => qb.select('simple_groups.uid').from('simple_groups').whereIn('uid', group_ids.concat(['kes'])); var membered_groups = qb => qb.select('uid').from('simple_groups').whereIn('uid', group_ids.concat(['kes']));
var directly_visible_simple_groups = qb => qb.with('membered_groups', membered_groups) var directly_visible_simple_groups = qb => qb.with('membered_groups', membered_groups)
.select('simple_groups.uid').from('simple_groups').distinct() .select('simple_groups.uid').from('simple_groups').distinct()
.innerJoin('membered_groups', .innerJoin('membered_groups',
......
...@@ -205,12 +205,15 @@ export const resolvers = { ...@@ -205,12 +205,15 @@ export const resolvers = {
__resolveType: function(obj) { __resolveType: function(obj) {
return obj.type; return obj.type;
}, }
},
Post: {
authors: (obj, args, context) => { authors: (obj, args, context) => {
console.log(obj);
return knex.select().from('groups').whereIn('uid', obj.authors); return knex.select().from('groups').whereIn('uid', obj.authors);
} }
}, },
Announcement: { Announcement: {
...@@ -246,21 +249,20 @@ export const resolvers = { ...@@ -246,21 +249,20 @@ export const resolvers = {
// @rights viewer(obj.uid) // @rights viewer(obj.uid)
Group: { Group: {
__resolveType: (obj) => { __resolveType: async (obj) => {
console.log(obj);
let isSimple = knex.select().from("groups").where("uid", obj.uid) switch(obj.type) {
.then(res => { case "simple":
console.log(res); return "SimpleGroup";
return res; case "meta":
}); return "MetaGroup";
}
return undefined;
} }
}, },
// @rights viewer(obj.uid) // @rights viewer(obj.uid)
SimpleGroup: { SimpleGroup: {
members: (obj, args, context) => { members: (obj, args, context) => {
return connectors.utilisateur.listMembers(context.user,obj.uid); return connectors.utilisateur.listMembers(context.user,obj.uid);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment