diff --git a/db/migrations/20180415160405_message_types.js b/db/migrations/20180415160405_message_types.js new file mode 100644 index 0000000000000000000000000000000000000000..6311e4e219dc6e3f4b9b8f1c30a70ca01c89783b --- /dev/null +++ b/db/migrations/20180415160405_message_types.js @@ -0,0 +1,39 @@ + +exports.up = async function(knex, Promise) { + await knex.schema.dropTable('posts'); + await knex.schema.table('messages', function(table){ + table.dropColumn('authors'); + }); + await knex.schema.createTable('private_post', function(table){ + table.inherits('messages'); + table.string('author_uid', 128).notNullable(); + table.enum('author_db', ['ldap']).notNullable().defaultTo('ldap'); + table.string('recipient_uid', 128).notNullable(); + }); + await knex.schema.createTable('question', function(table){ + table.inherits('messages'); + table.string('author_uid', 128).notNullable(); + table.enum('author_db', ['ldap']).notNullable().defaultTo('ldap'); + table.string('recipient_uid', 128).notNullable(); + }); + await knex.schema.createTable('answer', function(table){ + table.inherits('messages'); + table.string('author_uid', 128).notNullable(); + table.string('recipient_uid', 128).notNullable(); + table.string('for_question', 128).notNullable(); + }); + return; +}; + +exports.down = async function(knex, Promise) { + await knex.schema.dropTable('answer'); + await knex.schema.dropTable('question'); + await knex.schema.dropTable('private_post'); + await knex.schema.table('messages', function(table){ + table.specificType('authors', knex.raw('varchar(128)[]')); + }); + await knex.schema.createTable('posts', function(table) { + table.inherits('messages'); + }); + return; +}; diff --git a/src/graphql/typeDefs/actions.js b/src/graphql/typeDefs/actions.js index e5858aee1a6eb86fe4675fe7e9d46a2a79f668f7..b60fa653a2a950b2b8f8355171367cf3469e9658 100644 --- a/src/graphql/typeDefs/actions.js +++ b/src/graphql/typeDefs/actions.js @@ -15,8 +15,6 @@ const RootTypes = ` allMessages: [Message] message(id: ID!): Message - allPosts: [Post] - post(id: ID!): Post allEvents: [Event] allAnnouncements: [Announcement] @@ -198,7 +196,6 @@ const subQueries = ` type MessageQuery{ allMessages: [Message] allEvents: [Event] - allPosts: [Post] message(id: ID): Message allAnnouncements: [Announcement] } diff --git a/src/graphql/typeDefs/objects.js b/src/graphql/typeDefs/objects.js index 7c4b48772b064ea9b89c8048700036496dc9746f..08093c67a76d47443cf9b3330bc3496e6f428b6f 100644 --- a/src/graphql/typeDefs/objects.js +++ b/src/graphql/typeDefs/objects.js @@ -120,18 +120,6 @@ const Message = ` recipient: Recipient } - # Publication postée par un ou plusieurs groupes. - type Post implements Message { - id: ID! - title: String! - createdAt: String! - updatedAt: String! - content: String! - - authors: Author - recipient: Recipient - } - # Annonce publique effectuée par un ou plusieurs groupes. type Announcement implements Message { id: ID! @@ -168,6 +156,54 @@ const Message = ` authors: Author recipient: Recipient } + + # Post interne d'un membre sur la page interne de son groupe + type PrivatePost implements Message { + id: ID! + createdAt: String! + updatedAt: String! + title: String! + content: String! + + authors: User + recipient: Group + } + + # Question posée par un user à un groupe + type Question implements Message { + id: ID! + createdAt: String! + updatedAt: String! + title: String! + content: String! + + authors: User + recipient: Group + + # Une annonce éventuellement concernée par cette question. + # Null si la question ne concerne pas une annonce particulière + + forAnnouncement : Announcement + + # Référence la réponse donnée par le groupe à cette Question. Si pas encore répondu, null. + forAnswer: Answer + } + + # Réponse à une Question + type Answer implements Message { + id: ID! + createdAt: String! + updatedAt: String! + title: String! + content: String! + + authors: Group + recipient: Group + + # La question à laquelle cette Answer répond. Non-nullable bien sûr + forQuestion: Question! + } + `; const Requests = `