diff --git a/lib/etherpad/methods.js b/lib/etherpad/methods.js index 3d79fc2..d41bb21 100644 --- a/lib/etherpad/methods.js +++ b/lib/etherpad/methods.js @@ -3,6 +3,7 @@ const Logger = require('../utils/logger'); const logger = new Logger('methods'); const AUTHOR_ID = 'authorID'; +const AUTHOR_MAPPER = 'authorMapper'; const GROUP_ID = 'groupID'; const PAD_ID = 'padID'; const SESSION_ID = 'sessionID'; @@ -62,6 +63,12 @@ const methods = { optional: [AUTHOR_NAME], }, }, + createAuthorIfNotExistsFor: { + params: { + mandatory: [AUTHOR_MAPPER], + optional: [AUTHOR_NAME], + }, + }, listPadsOfAuthor: { params: { mandatory: [AUTHOR_ID], diff --git a/lib/redis/database.js b/lib/redis/database.js index 5fa3952..2e09084 100644 --- a/lib/redis/database.js +++ b/lib/redis/database.js @@ -406,7 +406,7 @@ const createUser = (meetingId, { return reject(); } - api.call('createAuthor', { name }).then(response => { + api.call('createAuthorIfNotExistsFor', { authorMapper: userId, name }).then(response => { const authorId = response.authorID; database[meetingId].users[userId] = { authorId,