feat: save conflict check polling
This commit is contained in:
		| @@ -147,7 +147,8 @@ router.get(['/e', '/e/*'], async (req, res, next) => { | ||||
|       mode: 'create', | ||||
|       content: null, | ||||
|       title: null, | ||||
|       description: null | ||||
|       description: null, | ||||
|       updatedAt: new Date().toISOString() | ||||
|     } | ||||
|  | ||||
|     // -> From Template | ||||
|   | ||||
| @@ -252,6 +252,24 @@ module.exports = { | ||||
|         } | ||||
|         return result | ||||
|       }, []) | ||||
|     }, | ||||
|     /** | ||||
|      * CHECK FOR EDITING CONFLICT | ||||
|      */ | ||||
|     async checkConflicts (obj, args, context, info) { | ||||
|       let page = await WIKI.models.pages.query().select('path', 'localeCode', 'updatedAt').findById(args.id) | ||||
|       if (page) { | ||||
|         if (WIKI.auth.checkAccess(context.req.user, ['write:pages', 'manage:pages'], { | ||||
|           path: page.path, | ||||
|           locale: page.localeCode | ||||
|         })) { | ||||
|           return page.updatedAt !== args.checkoutDate | ||||
|         } else { | ||||
|           throw new WIKI.Error.PageUpdateForbidden() | ||||
|         } | ||||
|       } else { | ||||
|         throw new WIKI.Error.PageNotFound() | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   PageMutation: { | ||||
|   | ||||
| @@ -61,6 +61,11 @@ type PageQuery { | ||||
|   links( | ||||
|     locale: String! | ||||
|   ): [PageLinkItem] @auth(requires: ["manage:system", "read:pages"]) | ||||
|  | ||||
|   checkConflicts( | ||||
|     id: Int! | ||||
|     checkoutDate: Date! | ||||
|   ): Boolean! @auth(requires: ["write:pages", "manage:pages", "manage:system"]) | ||||
| } | ||||
|  | ||||
| # ----------------------------------------------- | ||||
|   | ||||
| @@ -17,4 +17,5 @@ block body | ||||
|       init-mode=page.mode | ||||
|       init-editor=page.editorKey | ||||
|       init-content=page.content | ||||
|       checkout-date=page.updatedAt | ||||
|       ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user