diff --git a/README.md b/README.md index 4b9825d..b46f82e 100755 --- a/README.md +++ b/README.md @@ -113,6 +113,17 @@ the public key. To start syncing user \#1 should perform a get request to `/syncp2pdata`. Received new questions are automatically sent to registered peers. +`/syncp2pdata` accepts a few query parameters: + + | Name | Type | Description | + | --- | --- | --- | + | allTime | boolean | If it should ignore the last sync date, and get all data | + | users | boolean | If it should sync users | + | questions | boolean | If it should sync questions | + +If `users` and `questions` are all missing, then everything will be synced. The last sync date is +stored separately for them. + If the peer doesn't have a https server (only http) then `http: true` should be specified in `peers.json` diff --git a/src/modules/api/submodules/p2p.ts b/src/modules/api/submodules/p2p.ts index 686b907..a5abcd1 100644 --- a/src/modules/api/submodules/p2p.ts +++ b/src/modules/api/submodules/p2p.ts @@ -1338,15 +1338,15 @@ function setup(data: SubmoduleData): Submodule { const questions = !!req.query.questions const users = !!req.query.users const allTime = !!req.query.allTime - // const user = req.session.user + const user = req.session.user - // if (!user || user.id !== 1) { - // res.json({ - // status: 'error', - // message: 'only user 1 can call this EP', - // }) - // return - // } + if (!user || user.id !== 1) { + res.json({ + status: 'error', + message: 'only user 1 can call this EP', + }) + return + } // FIXME: /syncResult EP if this EP times out, but we still need the result if (syncInProgress) {