mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 12:53:34 -05:00
Merge pull request #10 from sharelatex/ho-delete-dict
added delete dic endpoint
This commit is contained in:
commit
748b285e47
5 changed files with 24 additions and 1 deletions
|
@ -19,6 +19,7 @@ HealthCheckController = require("./app/js/HealthCheckController")
|
||||||
server.use bodyParser.json(limit: "2mb")
|
server.use bodyParser.json(limit: "2mb")
|
||||||
server.use metrics.http.monitor(logger)
|
server.use metrics.http.monitor(logger)
|
||||||
|
|
||||||
|
server.del "/user/:user_id", SpellingAPIController.deleteDic
|
||||||
server.post "/user/:user_id/check", SpellingAPIController.check
|
server.post "/user/:user_id/check", SpellingAPIController.check
|
||||||
server.post "/user/:user_id/learn", SpellingAPIController.learn
|
server.post "/user/:user_id/learn", SpellingAPIController.learn
|
||||||
server.get "/status", (req, res)->
|
server.get "/status", (req, res)->
|
||||||
|
|
|
@ -29,6 +29,9 @@ module.exports = LearnedWordsManager =
|
||||||
mongoCache.set(user_token, words)
|
mongoCache.set(user_token, words)
|
||||||
callback null, words
|
callback null, words
|
||||||
|
|
||||||
|
deleteUsersLearnedWords: (user_token, callback =(error)->)->
|
||||||
|
db.spellingPreferences.remove token: user_token, callback
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'learnWord',
|
'learnWord',
|
||||||
|
|
|
@ -21,3 +21,9 @@ module.exports = SpellingAPIController =
|
||||||
next()
|
next()
|
||||||
|
|
||||||
|
|
||||||
|
deleteDic: (req, res, next)->
|
||||||
|
logger.log token: req?.params?.user_id, word: req?.body?.word, "deleting user dictionary"
|
||||||
|
SpellingAPIManager.deleteDic req.params.user_id, (error) ->
|
||||||
|
return next(error) if error?
|
||||||
|
res.sendStatus(204)
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,6 @@ module.exports = SpellingAPIManager =
|
||||||
|
|
||||||
LearnedWordsManager.learnWord token, request.word, callback
|
LearnedWordsManager.learnWord token, request.word, callback
|
||||||
|
|
||||||
|
deleteDic: (token, callback)->
|
||||||
|
LearnedWordsManager.deleteUsersLearnedWords token, callback
|
||||||
|
|
||||||
|
|
|
@ -84,3 +84,14 @@ describe "LearnedWordsManager", ->
|
||||||
@cache.del.calledWith(@token).should.equal true
|
@cache.del.calledWith(@token).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
||||||
|
describe "deleteUsersLearnedWords", ->
|
||||||
|
beforeEach ->
|
||||||
|
@db.spellingPreferences.delete = sinon.stub().callsArgWith(1)
|
||||||
|
|
||||||
|
|
||||||
|
it "should get the word list for the given user", (done)->
|
||||||
|
@LearnedWordsManager.deleteUsersLearnedWords @token, =>
|
||||||
|
@db.spellingPreferences.delete.calledWith(token: @token).should.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue