1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-10-06 22:17:10 +02:00

Clipper: Fixed: Added Chrome workaround to prevent it from posting the same note twice

This commit is contained in:
Laurent Cozic
2019-05-11 11:18:09 +01:00
parent 7628506926
commit 91ecab51c5
2 changed files with 57 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ class Api {
constructor(token = null) {
this.token_ = token;
this.knownNounces_ = {};
this.logger_ = new Logger();
}
@@ -62,9 +63,18 @@ class Api {
async route(method, path, query = null, body = null, files = null) {
if (!files) files = [];
if (!query) query = {};
const parsedPath = this.parsePath(path);
if (!parsedPath.callName) throw new ErrorNotFound(); // Nothing at the root yet
if (query && query.nounce) {
const requestMd5 = md5(JSON.stringify([method, path, body, query, files.length]));
if (this.knownNounces_[query.nounce] === requestMd5) {
throw new ErrorBadRequest('Duplicate Nounce');
}
this.knownNounces_[query.nounce] = requestMd5;
}
const request = {
method: method,