mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 06:04:25 +01:00
rpc-git: fix function calls
Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
const ACL = require('../acl')
|
||||||
|
|
||||||
async getReposHandler (publicKey, req) {
|
async function getReposHandler (publicKey, req) {
|
||||||
const { branch, url, userId } = await this.parseReq(publicKey, req)
|
const { branch, url, userId } = await parseReq.bind(this)(publicKey, req)
|
||||||
|
|
||||||
const res = {}
|
const res = {}
|
||||||
for (const repoName in this.repositories) {
|
for (const repoName in this.repositories) {
|
||||||
@@ -14,8 +15,8 @@ async getReposHandler (publicKey, req) {
|
|||||||
return Buffer.from(JSON.stringify(res))
|
return Buffer.from(JSON.stringify(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRefsHandler (publicKey, req) {
|
async function getRefsHandler (publicKey, req) {
|
||||||
const { repoName, branch, url, userId } = await this.parseReq(publicKey, req)
|
const { repoName, branch, url, userId } = await parseReq.bind(this)(publicKey, req)
|
||||||
const res = this.repositories[repoName]
|
const res = this.repositories[repoName]
|
||||||
|
|
||||||
const isPublic = (ACL.getACL(repoName).visibility === 'public')
|
const isPublic = (ACL.getACL(repoName).visibility === 'public')
|
||||||
@@ -26,8 +27,8 @@ async getRefsHandler (publicKey, req) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushHandler (publicKey, req) {
|
async function pushHandler (publicKey, req) {
|
||||||
const { url, repoName, branch, userId } = await this.parseReq(publicKey, req)
|
const { url, repoName, branch, userId } = await parseReq.bind(this)(publicKey, req)
|
||||||
const isContributor = ACL.getContributors(repoName).includes(userId)
|
const isContributor = ACL.getContributors(repoName).includes(userId)
|
||||||
|
|
||||||
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
||||||
@@ -51,8 +52,8 @@ async pushHandler (publicKey, req) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async forcePushHandler (publicKey, req) {
|
async function forcePushHandler (publicKey, req) {
|
||||||
const { url, repoName, branch, userId } = await this.parseReq(publicKey, req)
|
const { url, repoName, branch, userId } = await parseReq.bind(this)(publicKey, req)
|
||||||
const isContributor = ACL.getContributors(repoName).includes(userId)
|
const isContributor = ACL.getContributors(repoName).includes(userId)
|
||||||
|
|
||||||
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
||||||
@@ -76,8 +77,8 @@ async forcePushHandler (publicKey, req) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteBranchHandler (publicKey, req) {
|
async function deleteBranchHandler (publicKey, req) {
|
||||||
const { url, repoName, branch, userId } = await this.parseReq(publicKey, req)
|
const { url, repoName, branch, userId } = await parseReq.bind(this)(publicKey, req)
|
||||||
const isContributor = ACL.getContributors(repoName).includes(userId)
|
const isContributor = ACL.getContributors(repoName).includes(userId)
|
||||||
|
|
||||||
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
if (!isContributor) throw new Error('You are not allowed to push to this repo')
|
||||||
@@ -99,10 +100,9 @@ async forcePushHandler (publicKey, req) {
|
|||||||
return code === 0 ? resolve(errBuffer) : reject(errBuffer)
|
return code === 0 ? resolve(errBuffer) : reject(errBuffer)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function parseReq(publicKey, req) {
|
||||||
async parseReq(publicKey, req) {
|
|
||||||
if (!req) throw new Error('Request is empty')
|
if (!req) throw new Error('Request is empty')
|
||||||
const request = JSON.parse(req.toString())
|
const request = JSON.parse(req.toString())
|
||||||
const parsed = {
|
const parsed = {
|
||||||
|
|||||||
Reference in New Issue
Block a user