mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 10:19:10 +00:00
finish MVP
This commit is contained in:
parent
7806219464
commit
eaa1167f16
22 changed files with 486 additions and 116 deletions
|
@ -30,18 +30,36 @@ class ServerService extends Service {
|
|||
return srv.save()
|
||||
}
|
||||
|
||||
update (id, newData) {
|
||||
const srv = this.get(id)
|
||||
async update (id, newData) {
|
||||
const srv = await this.get(id, false)
|
||||
|
||||
return srv.update(newData)
|
||||
}
|
||||
|
||||
async get (id) {
|
||||
return (await this.Server.findOne({
|
||||
async get (id, plain = true) {
|
||||
const s = await this.Server.findOne({
|
||||
where: {
|
||||
id
|
||||
}
|
||||
})).get({ plain: true })
|
||||
})
|
||||
|
||||
if (!plain) {
|
||||
return s
|
||||
}
|
||||
|
||||
return s.get({ plain: true })
|
||||
}
|
||||
|
||||
async getAllowedRoles (id) {
|
||||
const server = await this.get(id)
|
||||
|
||||
return Object.values(server.categories).reduce((acc, c) => {
|
||||
if (c.hidden !== true) {
|
||||
return acc.concat(c.roles)
|
||||
}
|
||||
|
||||
return acc
|
||||
}, [])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue