2018-12-24 06:03:10 +00:00
|
|
|
const graphHelper = require('../../helpers/graph')
|
|
|
|
|
|
|
|
/* global WIKI */
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Query: {
|
|
|
|
async site() { return {} }
|
|
|
|
},
|
|
|
|
Mutation: {
|
|
|
|
async site() { return {} }
|
|
|
|
},
|
|
|
|
SiteQuery: {
|
|
|
|
async config(obj, args, context, info) {
|
|
|
|
return {
|
|
|
|
host: WIKI.config.host,
|
|
|
|
title: WIKI.config.title,
|
|
|
|
company: WIKI.config.company,
|
2019-12-19 04:45:19 +00:00
|
|
|
logoUrl: WIKI.config.logoUrl,
|
2018-12-24 06:03:10 +00:00
|
|
|
...WIKI.config.seo,
|
2019-08-25 02:19:35 +00:00
|
|
|
...WIKI.config.features,
|
|
|
|
...WIKI.config.security
|
2018-12-24 06:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SiteMutation: {
|
|
|
|
async updateConfig(obj, args, context) {
|
|
|
|
try {
|
|
|
|
WIKI.config.host = args.host
|
|
|
|
WIKI.config.title = args.title
|
|
|
|
WIKI.config.company = args.company
|
|
|
|
WIKI.config.seo = {
|
|
|
|
description: args.description,
|
|
|
|
robots: args.robots,
|
2019-01-01 22:03:30 +00:00
|
|
|
analyticsService: args.analyticsService,
|
|
|
|
analyticsId: args.analyticsId
|
2018-12-24 06:03:10 +00:00
|
|
|
}
|
2019-12-19 04:45:19 +00:00
|
|
|
WIKI.config.logoUrl = args.logoUrl
|
2018-12-24 06:03:10 +00:00
|
|
|
WIKI.config.features = {
|
|
|
|
featurePageRatings: args.featurePageRatings,
|
|
|
|
featurePageComments: args.featurePageComments,
|
|
|
|
featurePersonalWikis: args.featurePersonalWikis
|
|
|
|
}
|
2019-08-25 02:19:35 +00:00
|
|
|
WIKI.config.security = {
|
|
|
|
securityIframe: args.securityIframe,
|
|
|
|
securityReferrerPolicy: args.securityReferrerPolicy,
|
2019-10-05 20:58:34 +00:00
|
|
|
securityTrustProxy: args.securityTrustProxy,
|
2019-10-12 18:41:45 +00:00
|
|
|
securitySRI: args.securitySRI,
|
2019-08-25 02:19:35 +00:00
|
|
|
securityHSTS: args.securityHSTS,
|
|
|
|
securityHSTSDuration: args.securityHSTSDuration,
|
|
|
|
securityCSP: args.securityCSP,
|
|
|
|
securityCSPDirectives: args.securityCSPDirectives
|
|
|
|
}
|
2019-12-19 04:45:19 +00:00
|
|
|
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logoUrl', 'features', 'security'])
|
2018-12-24 06:03:10 +00:00
|
|
|
|
2019-10-05 20:58:34 +00:00
|
|
|
if (WIKI.config.security.securityTrustProxy) {
|
|
|
|
WIKI.app.enable('trust proxy')
|
|
|
|
} else {
|
|
|
|
WIKI.app.disable('trust proxy')
|
|
|
|
}
|
|
|
|
|
2018-12-24 06:03:10 +00:00
|
|
|
return {
|
|
|
|
responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
return graphHelper.generateError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|