da9224a069
feat: server & stream invites rework Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
23 lines
480 B
JavaScript
23 lines
480 B
JavaScript
const { StreamAcl } = require('@/modules/core/dbSchema')
|
|
|
|
/**
|
|
* Get the role user has for the specified stream
|
|
* @param {string} userId
|
|
* @param {string} streamId
|
|
* @returns {Promise<string>}
|
|
*/
|
|
async function getUserStreamRole(userId, streamId) {
|
|
const entry = await StreamAcl.knex()
|
|
.where({
|
|
[StreamAcl.col.resourceId]: streamId,
|
|
[StreamAcl.col.userId]: userId
|
|
})
|
|
.first()
|
|
|
|
return entry?.role || null
|
|
}
|
|
|
|
module.exports = {
|
|
getUserStreamRole
|
|
}
|