Skip to content
Snippets Groups Projects
Commit 6e9d0351 authored by Matheus CARIUS CASTRO's avatar Matheus CARIUS CASTRO
Browse files

Loads an announcement's authors and recipients

Adds the loading of an announcement's authors and recipients inside fetchData
parent 523bc3d4
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import {User} from './users';
import knex from '../../../db/knex_router';
import { Context } from '../typeDefs/queries';
import { ApolloError } from 'apollo-server-core';
import { GroupSet } from '../models/tools';
export abstract class Message {
......@@ -153,6 +154,8 @@ export class Announcement extends Message {
*/
constructor(mid: number) {
super(mid);
this.m_authors = new GroupSet();
this.m_recipients = new GroupSet();
}
/**
......@@ -201,12 +204,28 @@ export class Announcement extends Message {
this.m_views = m.views;
this.m_dataLoaded = true;
return true;
}
else {
return false;
}
//Charge les authors dans m_authors
data = await knex.select('gid').from('announcements_authors').where('mid', this.mid);
for(let t of data) {
this.m_authors.add(t.gid);
}
//Charge les recipients dans m_recipients
data = await knex.select('gid').from('announcements_recipients').where('mid', this.mid);
for (let t of data) {
this.m_authors.add(t.gid);
}
}
return true;
}
......@@ -219,6 +238,8 @@ export class Announcement extends Message {
*/
protected m_importance: number
protected m_views : number
protected m_authors : GroupSet
protected m_recipients : GroupSet
/**
* Ci-dessous les resolvers a proprement parler.
......@@ -234,7 +255,7 @@ export class Announcement extends Message {
*/
async authors(args, context: Context, info): Promise<Group[]> {
throw "Not implemented";
/*return knex.select({ uid: 'group' }).from('group_message_relationships')
.where('message', messageID).whereIn('status', ['host', 'publish']);*/
}
......
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