feat: save conflict resolution
This commit is contained in:
@@ -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: {
|
||||
|
@@ -66,6 +66,10 @@ type PageQuery {
|
||||
id: Int!
|
||||
checkoutDate: Date!
|
||||
): Boolean! @auth(requires: ["write:pages", "manage:pages", "manage:system"])
|
||||
|
||||
conflictLatest(
|
||||
id: Int!
|
||||
): PageConflictLatest! @auth(requires: ["write:pages", "manage:pages", "manage:system"])
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
@@ -277,6 +281,21 @@ type PageLinkItem {
|
||||
links: [String]!
|
||||
}
|
||||
|
||||
type PageConflictLatest {
|
||||
id: Int!
|
||||
authorId: String!
|
||||
authorName: String!
|
||||
content: String!
|
||||
createdAt: Date!
|
||||
description: String!
|
||||
isPublished: Boolean!
|
||||
locale: String!
|
||||
path: String!
|
||||
tags: [String]
|
||||
title: String!
|
||||
updatedAt: Date!
|
||||
}
|
||||
|
||||
enum PageOrderBy {
|
||||
CREATED
|
||||
ID
|
||||
|
Reference in New Issue
Block a user