feat: save conflict resolution

This commit is contained in:
NGPixel
2020-03-21 19:18:08 -04:00
parent bacbe4f543
commit 4b0e3d1c43
12 changed files with 400 additions and 31 deletions

View File

@@ -139,7 +139,7 @@ module.exports = {
async single (obj, args, context, info) {
let page = await WIKI.models.pages.getPageFromDb(args.id)
if (page) {
if (WIKI.auth.checkAccess(context.req.user, ['read:history'], {
if (WIKI.auth.checkAccess(context.req.user, ['manage:pages', 'delete:pages'], {
path: page.path,
locale: page.localeCode
})) {
@@ -263,13 +263,35 @@ module.exports = {
path: page.path,
locale: page.localeCode
})) {
return page.updatedAt !== args.checkoutDate
return page.updatedAt > args.checkoutDate
} else {
throw new WIKI.Error.PageUpdateForbidden()
}
} else {
throw new WIKI.Error.PageNotFound()
}
},
/**
* FETCH LATEST VERSION FOR CONFLICT COMPARISON
*/
async conflictLatest (obj, args, context, info) {
let page = await WIKI.models.pages.getPageFromDb(args.id)
if (page) {
if (WIKI.auth.checkAccess(context.req.user, ['write:pages', 'manage:pages'], {
path: page.path,
locale: page.localeCode
})) {
return {
...page,
tags: page.tags.map(t => t.tag),
locale: page.localeCode
}
} else {
throw new WIKI.Error.PageViewForbidden()
}
} else {
throw new WIKI.Error.PageNotFound()
}
}
},
PageMutation: {