From 395cfe4adeb6823f28b12754db03f97d3eaf26b6 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 18 Sep 2018 16:59:21 -0600 Subject: [PATCH] feat: added reaction configuration --- .../server/graph/tenant/schema/schema.graphql | 37 ++++++++++++++++--- src/core/server/models/settings.ts | 6 +++ src/core/server/models/tenant.ts | 12 ++++-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/core/server/graph/tenant/schema/schema.graphql b/src/core/server/graph/tenant/schema/schema.graphql index 424a777e5..10fa82564 100644 --- a/src/core/server/graph/tenant/schema/schema.graphql +++ b/src/core/server/graph/tenant/schema/schema.graphql @@ -471,6 +471,26 @@ type Email { fromAddress: String } +################################################################################ +## ReactionConfiguration +################################################################################ + +""" +ReactionConfiguration stores the configuration for reactions used across this +Tenant. +""" +type ReactionConfiguration { + """ + label is the string placed beside the reaction icon to provide better context. + """ + label: String! + + """ + icon is the string representing the icon to be used for the reactions. + """ + icon: String! +} + ################################################################################ ## Settings ################################################################################ @@ -584,22 +604,22 @@ type Settings { """ organizationName is the name of the organization. """ - organizationName: String + organizationName: String! """ organizationContactEmail is the email of the organization. """ - organizationContactEmail: String + organizationContactEmail: String! """ email is the set of credentials and settings associated with the organization. """ - email: Email @auth(roles: [ADMIN]) + email: Email! @auth(roles: [ADMIN]) """ wordlist will return a given list of words. """ - wordlist: Wordlist @auth(roles: [ADMIN, MODERATOR]) + wordlist: Wordlist! @auth(roles: [ADMIN, MODERATOR]) """ auth contains all the settings related to authentication and authorization. @@ -609,13 +629,18 @@ type Settings { """ integrations contains all the external integrations that can be enabled. """ - integrations: ExternalIntegrations @auth(roles: [ADMIN]) + integrations: ExternalIntegrations! @auth(roles: [ADMIN]) """ karma is the set of settings related to how user Trust and Karma are handled. """ - karma: Karma @auth(roles: [ADMIN, MODERATOR]) + karma: Karma! @auth(roles: [ADMIN, MODERATOR]) + + """ + reaction specifies the configuration for reactions. + """ + reaction: ReactionConfiguration! @auth(roles: [ADMIN]) } ################################################################################ diff --git a/src/core/server/models/settings.ts b/src/core/server/models/settings.ts index 451bfdf7a..00f25282a 100644 --- a/src/core/server/models/settings.ts +++ b/src/core/server/models/settings.ts @@ -4,6 +4,7 @@ import { GQLExternalIntegrations, GQLKarma, GQLMODERATION_MODE, + GQLReactionConfiguration, GQLWordlist, } from "talk-server/graph/tenant/schema/__generated__/types"; @@ -101,4 +102,9 @@ export interface Settings extends ModerationSettings { * Various integrations with external services. */ integrations: GQLExternalIntegrations; + + /** + * reaction specifies the configuration for reactions. + */ + reaction: GQLReactionConfiguration; } diff --git a/src/core/server/models/tenant.ts b/src/core/server/models/tenant.ts index f67982e6d..e11d55b2c 100644 --- a/src/core/server/models/tenant.ts +++ b/src/core/server/models/tenant.ts @@ -49,10 +49,10 @@ export type CreateTenantInput = Pick< /** * create will create a new Tenant. * - * @param db the MongoDB connection used to create the tenant. + * @param mongo the MongoDB connection used to create the tenant. * @param input the customizable parts of the Tenant available during creation */ -export async function createTenant(db: Db, input: CreateTenantInput) { +export async function createTenant(mongo: Db, input: CreateTenantInput) { const defaults: Sub = { // Create a new ID. id: uuid.v4(), @@ -115,6 +115,12 @@ export async function createTenant(db: Db, input: CreateTenantInput) { enabled: false, }, }, + reaction: { + // By default, the standard reaction style will use the Respect with the + // handshake. + label: "Respect", + icon: "handshake", + }, }; // Create the new Tenant by merging it together with the defaults. @@ -124,7 +130,7 @@ export async function createTenant(db: Db, input: CreateTenantInput) { }; // Insert the Tenant into the database. - await collection(db).insert(tenant); + await collection(mongo).insert(tenant); return tenant; }