pull/8027/merge
Dalibor Marković 5 days ago committed by GitHub
commit ced29670fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -620,7 +620,7 @@ export default {
Prism.highlightAllUnder(this.$refs.container)
// -> Render Mermaid diagrams
mermaid.mermaidAPI.initialize({
mermaid.initialize({
startOnLoad: true,
theme: this.$vuetify.theme.dark ? `dark` : `default`
})

@ -57,21 +57,21 @@
"bluebird": "3.7.2",
"body-parser": "1.20.1",
"chalk": "4.1.0",
"cheerio": "1.0.0-rc.5",
"chokidar": "3.5.3",
"cheerio": "1.2.0",
"chokidar": "4.0.3",
"chromium-pickle-js": "0.2.0",
"clean-css": "5.3.3",
"command-exists": "1.2.9",
"compression": "1.8.1",
"connect-session-knex": "2.0.0",
"connect-session-knex": "5.0.0",
"cookie-parser": "1.4.7",
"cors": "2.8.5",
"cors": "2.8.6",
"cuint": "0.2.2",
"custom-error-instance": "2.1.2",
"dependency-graph": "0.11.0",
"diff": "4.0.2",
"diff2html": "3.1.14",
"dompurify": "3.3.1",
"dompurify": "3.4.10",
"dotize": "0.3.0",
"elasticsearch6": "npm:@elastic/elasticsearch@6",
"elasticsearch7": "npm:@elastic/elasticsearch@7",
@ -83,7 +83,7 @@
"express-session": "1.18.2",
"file-type": "15.0.1",
"filesize": "6.1.0",
"fs-extra": "9.0.1",
"fs-extra": "11.3.5",
"getos": "3.2.1",
"graphql": "15.3.0",
"graphql-list-fields": "2.0.2",
@ -91,36 +91,36 @@
"graphql-subscriptions": "1.1.0",
"graphql-tools": "7.0.0",
"he": "1.2.0",
"highlight.js": "10.3.1",
"highlight.js": "11.11.1",
"i18next": "19.8.3",
"i18next-express-middleware": "2.0.0",
"i18next-node-fs-backend": "2.1.3",
"image-size": "0.9.2",
"js-base64": "3.7.8",
"js-binary": "1.2.0",
"js-yaml": "3.14.0",
"js-yaml": "4.2.0",
"jsdom": "16.4.0",
"jsonwebtoken": "9.0.3",
"katex": "0.12.0",
"klaw": "3.0.0",
"knex": "0.21.7",
"lodash": "4.17.21",
"luxon": "1.25.0",
"markdown-it": "11.0.1",
"markdown-it-abbr": "1.0.4",
"markdown-it-attrs": "3.0.3",
"knex": "3.2.10",
"lodash": "4.18.1",
"luxon": "3.7.2",
"markdown-it": "14.2.0",
"markdown-it-abbr": "2.0.0",
"markdown-it-attrs": "5.0.0",
"markdown-it-decorate": "1.2.2",
"markdown-it-emoji": "3.0.0",
"markdown-it-expand-tabs": "1.0.13",
"markdown-it-external-links": "0.0.6",
"markdown-it-footnote": "3.0.3",
"markdown-it-footnote": "4.0.0",
"markdown-it-imsize": "2.0.1",
"markdown-it-mark": "3.0.1",
"markdown-it-mark": "4.0.0",
"markdown-it-mathjax": "2.0.0",
"markdown-it-multimd-table": "4.0.3",
"markdown-it-multimd-table": "4.2.3",
"markdown-it-pivot-table": "1.0.5",
"markdown-it-sub": "1.0.0",
"markdown-it-sup": "1.0.0",
"markdown-it-sub": "2.0.0",
"markdown-it-sup": "2.0.0",
"markdown-it-task-lists": "2.1.1",
"mathjax": "3.2.2",
"mime-types": "2.1.35",
@ -130,13 +130,13 @@
"ms": "2.1.3",
"mssql": "6.2.3",
"multer": "1.4.4",
"mysql2": "3.16.0",
"mysql2": "3.22.5",
"nanoid": "3.2.0",
"node-2fa": "1.1.2",
"node-cache": "5.1.2",
"nodemailer": "6.9.1",
"objection": "2.2.18",
"passport": "0.4.1",
"nodemailer": "8.0.11",
"objection": "3.1.5",
"passport": "0.7.0",
"passport-auth0": "1.4.5",
"passport-azure-ad": "4.3.5",
"passport-cas": "0.1.1",
@ -158,7 +158,7 @@
"passport-twitch-strategy": "2.2.0",
"patch-package": "8.0.1",
"pem-jwk": "2.0.0",
"pg": "8.16.3",
"pg": "8.21.0",
"pg-hstore": "2.3.4",
"pg-pubsub": "0.8.1",
"pg-query-stream": "4.10.3",
@ -169,14 +169,12 @@
"qr-image": "3.2.0",
"raven": "2.6.4",
"remove-markdown": "0.6.2",
"request": "2.88.2",
"request-promise": "4.2.6",
"safe-regex": "2.1.1",
"sanitize-filename": "1.6.3",
"scim-query-filter-parser": "2.0.4",
"semver": "7.7.3",
"semver": "7.8.4",
"serve-favicon": "2.5.1",
"simple-git": "3.30.0",
"simple-git": "3.36.0",
"solr-node": "1.2.1",
"sqlite3": "5.1.7",
"ssh2": "1.11.0",
@ -189,7 +187,8 @@
"uslug": "1.0.4",
"uuid": "9.0.0",
"validate.js": "0.13.1",
"winston": "3.8.2",
"vuetify-loader": "1.6.0",
"winston": "3.19.0",
"xss": "1.0.15",
"yargs": "17.6.2"
},
@ -240,7 +239,7 @@
"codemirror-asciidoc": "1.0.4",
"copy-webpack-plugin": "6.2.1",
"core-js": "3.6.5",
"cross-env": "10.0.0",
"cross-env": "10.1.0",
"css-loader": "4.3.0",
"cssnano": "4.1.10",
"cypress": "5.3.0",
@ -292,7 +291,7 @@
"pug-plain-loader": "1.0.0",
"raw-loader": "4.0.2",
"resolve-url-loader": "3.1.2",
"sass": "1.27.0",
"sass": "1.101.0",
"sass-loader": "10.0.4",
"sass-resources-loader": "2.1.1",
"script-ext-html-webpack-plugin": "2.1.5",
@ -318,7 +317,6 @@
"vuedraggable": "2.24.3",
"vuescroll": "4.16.1",
"vuetify": "2.3.15",
"vuetify-loader": "1.6.0",
"vuex": "3.5.1",
"vuex-pathify": "1.4.5",
"vuex-persistedstate": "3.1.0",

@ -32,12 +32,12 @@ module.exports = {
let appdata = {}
try {
appconfig = yaml.safeLoad(
appconfig = yaml.load(
cfgHelper.parseConfigValue(
fs.readFileSync(confPaths.config, 'utf8')
)
)
appdata = yaml.safeLoad(fs.readFileSync(confPaths.data, 'utf8'))
appdata = yaml.load(fs.readFileSync(confPaths.data, 'utf8'))
appdata.regex = require(confPaths.dataRegex)
console.info(chalk.green.bold(`OK`))
} catch (err) {

@ -80,7 +80,7 @@ module.exports = {
try {
const devEntriesRaw = await fs.readFile(path.join(WIKI.SERVERPATH, `locales/${locale}.yml`), 'utf8')
if (devEntriesRaw) {
const devEntries = yaml.safeLoad(devEntriesRaw)
const devEntries = yaml.load(devEntriesRaw)
_.forOwn(devEntries, (data, ns) => {
this.namespaces.push(ns)
this.engine.addResourceBundle(locale, ns, data, true, true)

@ -1,4 +1,3 @@
const request = require('request-promise')
const _ = require('lodash')
/* global WIKI */
@ -10,16 +9,20 @@ module.exports = {
ContributeQuery: {
async contributors(obj, args, context, info) {
try {
const resp = await request({
const resp = await fetch('https://graph.requarks.io', {
method: 'POST',
uri: 'https://graph.requarks.io',
json: true,
body: {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: '{\n sponsors {\n list(kind: BACKER) {\n id\n source\n name\n joined\n website\n twitter\n avatar\n }\n }\n}\n',
variables: {}
}
}),
signal: AbortSignal.timeout(10000)
})
return _.get(resp, 'data.sponsors.list', [])
if (!resp.ok) {
throw new Error(`Contributors fetch failed with status ${resp.status}`)
}
const data = await resp.json()
return _.get(data, 'data.sponsors.list', [])
} catch (err) {
WIKI.logger.warn(err)
}

@ -96,8 +96,8 @@ module.exports = {
async create (obj, args, { req }) {
const group = await WIKI.models.groups.query().insertAndFetch({
name: args.name,
permissions: JSON.stringify(WIKI.data.groups.defaultPermissions),
pageRules: JSON.stringify(WIKI.data.groups.defaultPageRules),
permissions: WIKI.data.groups.defaultPermissions,
pageRules: WIKI.data.groups.defaultPageRules,
isSystem: false
})
await WIKI.auth.reloadGroups()
@ -193,8 +193,8 @@ module.exports = {
await WIKI.models.groups.query().patch({
name: args.name,
redirectOnLogin: args.redirectOnLogin,
permissions: JSON.stringify(args.permissions),
pageRules: JSON.stringify(args.pageRules)
permissions: args.permissions,
pageRules: args.pageRules
}).where('id', args.id)
// Revoke tokens for this group

@ -6,7 +6,6 @@ const path = require('path')
const fs = require('fs-extra')
const moment = require('moment')
const graphHelper = require('../../helpers/graph')
const request = require('request-promise')
const crypto = require('crypto')
const nanoid = require('nanoid/non-secure').customAlphabet('1234567890abcdef', 10)
@ -89,13 +88,14 @@ module.exports = {
async performUpgrade (obj, args, context) {
try {
if (process.env.UPGRADE_COMPANION) {
await request({
method: 'POST',
uri: 'http://wiki-update-companion/upgrade',
qs: {
...process.env.UPGRADE_COMPANION_REF && { container: process.env.UPGRADE_COMPANION_REF }
}
})
const upgradeUrl = new URL('http://wiki-update-companion/upgrade')
if (process.env.UPGRADE_COMPANION_REF) {
upgradeUrl.searchParams.set('container', process.env.UPGRADE_COMPANION_REF)
}
const upgradeResp = await fetch(upgradeUrl, { method: 'POST', signal: AbortSignal.timeout(30000) })
if (!upgradeResp.ok) {
throw new Error(`Upgrade companion returned ${upgradeResp.status}`)
}
return {
responseResult: graphHelper.generateSuccess('Upgrade has started.')
}
@ -134,8 +134,8 @@ module.exports = {
if (args.groupMode === `SINGLE`) {
const singleGroup = await WIKI.models.groups.query().insert({
name: `Import_${curDateISO}`,
permissions: JSON.stringify(WIKI.data.groups.defaultPermissions),
pageRules: JSON.stringify(WIKI.data.groups.defaultPageRules)
permissions: WIKI.data.groups.defaultPermissions,
pageRules: WIKI.data.groups.defaultPageRules
})
groupsCount++
assignableGroups.push(singleGroup.id)
@ -184,8 +184,8 @@ module.exports = {
const newGroup = await WIKI.models.groups.query().insert({
name: `Import_${curDateISO}_${groupsCount + 1}`,
permissions: JSON.stringify(perms),
pageRules: JSON.stringify(pageRules)
permissions: perms,
pageRules: pageRules
})
reuseGroups.push({
groupId: newGroup.id,

@ -5,7 +5,8 @@ const cookieParser = require('cookie-parser')
const cors = require('cors')
const express = require('express')
const session = require('express-session')
const KnexSessionStore = require('connect-session-knex')(session)
const { ConnectSessionKnexStore } = require('connect-session-knex')
const KnexSessionStore = ConnectSessionKnexStore
const favicon = require('serve-favicon')
const path = require('path')
const _ = require('lodash')

@ -21,15 +21,12 @@ module.exports = class Analytics extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'}
isEnabled: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getProviders(isEnabled) {
const providers = await WIKI.models.analytics.query().where(_.isBoolean(isEnabled) ? { isEnabled } : {})
return _.sortBy(providers, ['key'])
@ -45,7 +42,7 @@ module.exports = class Analytics extends Model {
let diskProviders = []
for (let dir of analyticsDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/analytics', dir, 'definition.yml'), 'utf8')
diskProviders.push(yaml.safeLoad(def))
diskProviders.push(yaml.load(def))
}
WIKI.data.analytics = diskProviders.map(provider => ({
...provider,
@ -111,7 +108,7 @@ module.exports = class Analytics extends Model {
for (let provider of providers) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/analytics', provider.key, 'code.yml'), 'utf8')
let code = yaml.safeLoad(def)
let code = yaml.load(def)
code.head = _.defaultTo(code.head, '')
code.bodyStart = _.defaultTo(code.bodyStart, '')
code.bodyEnd = _.defaultTo(code.bodyEnd, '')

@ -21,15 +21,14 @@ module.exports = class Authentication extends Model {
properties: {
key: {type: 'string'},
selfRegistration: {type: 'boolean'}
selfRegistration: {type: 'boolean'},
config: {type: 'object'},
domainWhitelist: {type: 'object'},
autoEnrollGroups: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config', 'domainWhitelist', 'autoEnrollGroups']
}
static async getStrategy(key) {
return WIKI.models.authentication.query().findOne({ key })
}
@ -84,7 +83,7 @@ module.exports = class Authentication extends Model {
WIKI.data.authentication = []
for (let dir of authDirs) {
const defRaw = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/authentication', dir, 'definition.yml'), 'utf8')
const def = yaml.safeLoad(defRaw)
const def = yaml.load(defRaw)
WIKI.data.authentication.push({
...def,
props: commonHelper.parseModuleProps(def.props)

@ -21,15 +21,12 @@ module.exports = class CommentProvider extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'}
isEnabled: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getProvider(key) {
return WIKI.models.commentProviders.query().findOne({ key })
}
@ -49,7 +46,7 @@ module.exports = class CommentProvider extends Model {
let diskProviders = []
for (let dir of commentDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/comments', dir, 'definition.yml'), 'utf8')
diskProviders.push(yaml.safeLoad(def))
diskProviders.push(yaml.load(def))
}
WIKI.data.commentProviders = diskProviders.map(provider => ({
...provider,
@ -111,7 +108,7 @@ module.exports = class CommentProvider extends Model {
if (WIKI.data.commentProvider.codeTemplate) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/comments', commentProvider.key, 'code.yml'), 'utf8')
let code = yaml.safeLoad(def)
let code = yaml.load(def)
code.head = _.defaultTo(code.head, '')
code.body = _.defaultTo(code.body, '')
code.main = _.defaultTo(code.main, '')

@ -21,15 +21,12 @@ module.exports = class Editor extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'}
isEnabled: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getEditors() {
return WIKI.models.editors.query()
}
@ -44,7 +41,7 @@ module.exports = class Editor extends Model {
let diskEditors = []
for (let dir of editorDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/editor', dir, 'definition.yml'), 'utf8')
diskEditors.push(yaml.safeLoad(def))
diskEditors.push(yaml.load(def))
}
WIKI.data.editors = diskEditors.map(editor => ({
...editor,

@ -14,6 +14,8 @@ module.exports = class Group extends Model {
properties: {
id: {type: 'integer'},
name: {type: 'string'},
permissions: {type: 'array'},
pageRules: {type: 'array'},
isSystem: {type: 'boolean'},
redirectOnLogin: {type: 'string'},
createdAt: {type: 'string'},
@ -22,10 +24,6 @@ module.exports = class Group extends Model {
}
}
static get jsonAttributes() {
return ['permissions', 'pageRules']
}
static get relationMappings() {
return {
users: {

@ -21,15 +21,12 @@ module.exports = class Locale extends Model {
nativeName: {type: 'string'},
createdAt: {type: 'string'},
updatedAt: {type: 'string'},
availability: {type: 'integer'}
availability: {type: 'integer'},
strings: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['strings']
}
$beforeUpdate() {
this.updatedAt = new Date().toISOString()
}

@ -22,15 +22,12 @@ module.exports = class Logger extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'},
level: {type: 'string'}
level: {type: 'string'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getLoggers() {
return WIKI.models.loggers.query()
}
@ -45,7 +42,7 @@ module.exports = class Logger extends Model {
let diskLoggers = []
for (let dir of loggersDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/logging', dir, 'definition.yml'), 'utf8')
diskLoggers.push(yaml.safeLoad(def))
diskLoggers.push(yaml.load(def))
}
WIKI.data.loggers = diskLoggers.map(logger => ({
...logger,

@ -49,15 +49,12 @@ module.exports = class Page extends Model {
contentType: {type: 'string'},
createdAt: {type: 'string'},
updatedAt: {type: 'string'}
updatedAt: {type: 'string'},
extra: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['extra']
}
static get relationMappings() {
return {
tags: {
@ -199,7 +196,7 @@ module.exports = class Page extends Model {
result = frontmatterRegex.markdown.exec(raw)
if (result[2]) {
return {
...yaml.safeLoad(result[2]),
...yaml.load(result[2]),
content: result[3]
}
} else {
@ -218,7 +215,7 @@ module.exports = class Page extends Model {
result = frontmatterRegex.html.exec(raw)
if (result[2]) {
return {
...yaml.safeLoad(result[2]),
...yaml.load(result[2]),
content: result[3]
}
}
@ -312,10 +309,10 @@ module.exports = class Page extends Model {
publishStartDate: opts.publishStartDate || '',
title: opts.title,
toc: '[]',
extra: JSON.stringify({
extra: {
js: scriptJs,
css: scriptCss
})
}
})
const page = await WIKI.models.pages.getPageFromDb({
path: opts.path,
@ -431,11 +428,11 @@ module.exports = class Page extends Model {
publishEndDate: opts.publishEndDate || '',
publishStartDate: opts.publishStartDate || '',
title: opts.title,
extra: JSON.stringify({
extra: {
...ogPage.extra,
js: scriptJs,
css: scriptCss
})
}
}).where('id', ogPage.id)
let page = await WIKI.models.pages.getPageFromDb(ogPage.id)

@ -22,15 +22,12 @@ module.exports = class Renderer extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'}
isEnabled: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getRenderers() {
return WIKI.models.renderers.query()
}
@ -40,7 +37,7 @@ module.exports = class Renderer extends Model {
let diskRenderers = []
for (let dir of rendererDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/rendering', dir, 'definition.yml'), 'utf8')
diskRenderers.push(yaml.safeLoad(def))
diskRenderers.push(yaml.load(def))
}
WIKI.data.renderers = diskRenderers.map(renderer => ({
...renderer,

@ -22,15 +22,12 @@ module.exports = class SearchEngine extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'},
level: {type: 'string'}
level: {type: 'string'},
config: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config']
}
static async getSearchEngines() {
return WIKI.models.searchEngines.query()
}
@ -45,7 +42,7 @@ module.exports = class SearchEngine extends Model {
let diskSearchEngines = []
for (let dir of searchEnginesDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/search', dir, 'definition.yml'), 'utf8')
diskSearchEngines.push(yaml.safeLoad(def))
diskSearchEngines.push(yaml.load(def))
}
WIKI.data.searchEngines = diskSearchEngines.map(searchEngine => ({
...searchEngine,

@ -17,16 +17,13 @@ module.exports = class Setting extends Model {
properties: {
key: {type: 'string'},
value: {type: 'object'},
createdAt: {type: 'string'},
updatedAt: {type: 'string'}
}
}
}
static get jsonAttributes() {
return ['value']
}
$beforeUpdate() {
this.updatedAt = new Date().toISOString()
}

@ -22,15 +22,13 @@ module.exports = class Storage extends Model {
properties: {
key: {type: 'string'},
isEnabled: {type: 'boolean'},
mode: {type: 'string'}
mode: {type: 'string'},
config: {type: 'object'},
state: {type: 'object'}
}
}
}
static get jsonAttributes() {
return ['config', 'state']
}
static async getTargets() {
return WIKI.models.storage.query()
}
@ -45,7 +43,7 @@ module.exports = class Storage extends Model {
let diskTargets = []
for (let dir of storageDirs) {
const def = await fs.readFile(path.join(WIKI.SERVERPATH, 'modules/storage', dir, 'definition.yml'), 'utf8')
diskTargets.push(yaml.safeLoad(def))
diskTargets.push(yaml.load(def))
}
WIKI.data.storage = diskTargets.map(target => ({
...target,

@ -28,7 +28,7 @@ module.exports = class User extends Model {
providerId: {type: 'string'},
password: {type: 'string'},
tfaIsActive: {type: 'boolean', default: false},
tfaSecret: {type: ['string', null]},
tfaSecret: {type: 'string', nullable: true},
jobTitle: {type: 'string'},
location: {type: 'string'},
pictureUrl: {type: 'string'},

@ -1,21 +1,24 @@
const request = require('request-promise')
const prefetch = async (element) => {
const url = element.attr(`src`)
let response
try {
response = await request({
method: `GET`,
url,
resolveWithFullResponse: true
})
response = await fetch(url, { signal: AbortSignal.timeout(10000) })
} catch (err) {
WIKI.logger.warn(`Failed to prefetch ${url}`)
WIKI.logger.warn(err)
return
}
const contentType = response.headers[`content-type`]
const image = Buffer.from(response.body).toString('base64')
if (!response.ok) {
WIKI.logger.warn(`Failed to prefetch ${url}: HTTP ${response.status}`)
return
}
const contentType = response.headers.get('content-type')
if (!contentType) {
WIKI.logger.warn(`Failed to prefetch ${url}: missing content-type`)
return
}
const buffer = await response.arrayBuffer()
const image = Buffer.from(buffer).toString('base64')
element.attr('src', `data:${contentType};base64,${image}`)
element.removeClass('prefetch-candidate')
}

@ -1,6 +1,5 @@
const _ = require('lodash')
const { SearchService, QueryType } = require('azure-search-client')
const request = require('request-promise')
const { pipeline } = require('node:stream/promises')
const { Transform } = require('node:stream')
@ -100,25 +99,27 @@ module.exports = {
top: 50
})
if (results.result.value.length < 5) {
// Using plain request, not yet available in library...
// Using native fetch, not yet available in library...
try {
const suggestResults = await request({
uri: `https://${this.config.serviceName}.search.windows.net/indexes/${this.config.indexName}/docs/autocomplete`,
method: 'post',
qs: {
'api-version': '2017-11-11-Preview'
},
const suggestUrl = new URL(`https://${this.config.serviceName}.search.windows.net/indexes/${this.config.indexName}/docs/autocomplete`)
suggestUrl.searchParams.set('api-version', '2017-11-11-Preview')
const suggestResp = await fetch(suggestUrl, {
method: 'POST',
headers: {
'api-key': this.config.adminKey,
'Content-Type': 'application/json'
},
json: true,
body: {
body: JSON.stringify({
autocompleteMode: 'oneTermWithContext',
search: q,
suggesterName: 'suggestions'
}
}),
signal: AbortSignal.timeout(10000)
})
if (!suggestResp.ok) {
throw new Error(`Azure autocomplete returned ${suggestResp.status}`)
}
const suggestResults = await suggestResp.json()
suggestions = suggestResults.value.map(s => s.queryPlusText)
} catch (err) {
WIKI.logger.warn('Search Engine suggestion failure: ', err)

@ -239,16 +239,14 @@ module.exports = () => {
WIKI.logger.info('Creating default groups...')
const adminGroup = await WIKI.models.groups.query().insert({
name: 'Administrators',
permissions: JSON.stringify(['manage:system']),
pageRules: JSON.stringify([]),
permissions: ['manage:system'],
pageRules: [],
isSystem: true
})
const guestGroup = await WIKI.models.groups.query().insert({
name: 'Guests',
permissions: JSON.stringify(['read:pages', 'read:assets', 'read:comments']),
pageRules: JSON.stringify([
{ id: 'guest', roles: ['read:pages', 'read:assets', 'read:comments'], match: 'START', deny: false, path: '', locales: [] }
]),
permissions: ['read:pages', 'read:assets', 'read:comments'],
pageRules: [{ id: 'guest', roles: ['read:pages', 'read:assets', 'read:comments'], match: 'START', deny: false, path: '', locales: [] }],
isSystem: true
})
if (adminGroup.id !== 1 || guestGroup.id !== 2) {
@ -392,7 +390,9 @@ module.exports = () => {
error: WIKI.IS_DEBUG ? err : {}
})
WIKI.logger.error(err.message)
WIKI.telemetry.sendError(err)
if (WIKI.telemetry) {
WIKI.telemetry.sendError(err)
}
})
// ----------------------------------------

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save