Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Kitsukey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kio!
Kitsukey
Commits
0085b1ac
Commit
0085b1ac
authored
1 year ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
bcacebc8
Branches
refine-moderation-log
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/core/RoleService.ts
+20
-0
20 additions, 0 deletions
packages/backend/src/core/RoleService.ts
packages/backend/src/server/api/endpoints/admin/roles/update.ts
+5
-7
5 additions, 7 deletions
...es/backend/src/server/api/endpoints/admin/roles/update.ts
with
25 additions
and
7 deletions
packages/backend/src/core/RoleService.ts
+
20
−
0
View file @
0085b1ac
...
...
@@ -455,6 +455,26 @@ export class RoleService implements OnApplicationShutdown {
redisPipeline
.
exec
();
}
@
bindThis
public
async
update
(
role
:
Role
,
params
:
Partial
<
Role
>
,
moderator
?:
User
):
Promise
<
void
>
{
const
date
=
new
Date
();
await
this
.
rolesRepository
.
update
(
role
.
id
,
{
updatedAt
:
date
,
...
params
,
});
const
updated
=
await
this
.
rolesRepository
.
findOneByOrFail
({
id
:
role
.
id
});
this
.
globalEventService
.
publishInternalEvent
(
'
roleUpdated
'
,
updated
);
if
(
moderator
)
{
this
.
moderationLogService
.
log
(
moderator
,
'
roleUpdated
'
,
{
roleId
:
role
.
id
,
before
:
role
,
after
:
updated
,
});
}
}
@
bindThis
public
dispose
():
void
{
this
.
redisForSub
.
off
(
'
message
'
,
this
.
onMessage
);
...
...
This diff is collapsed.
Click to expand it.
packages/backend/src/server/api/endpoints/admin/roles/update.ts
+
5
−
7
View file @
0085b1ac
import
{
Inject
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
Endpoint
}
from
'
@/server/api/endpoint-base.js
'
;
import
type
{
RolesRepository
}
from
'
@/models/index.js
'
;
import
{
GlobalEventService
}
from
'
@/core/GlobalEventService.js
'
;
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
{
ApiError
}
from
'
@/server/api/error.js
'
;
import
{
RoleService
}
from
'
@/core/RoleService.js
'
;
export
const
meta
=
{
tags
:
[
'
admin
'
,
'
role
'
],
...
...
@@ -66,16 +66,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
@
Inject
(
DI
.
rolesRepository
)
private
rolesRepository
:
RolesRepository
,
private
globalEventService
:
GlobalEvent
Service
,
private
roleService
:
Role
Service
,
)
{
super
(
meta
,
paramDef
,
async
(
ps
)
=>
{
super
(
meta
,
paramDef
,
async
(
ps
,
me
)
=>
{
const
role
=
await
this
.
rolesRepository
.
findOneBy
({
id
:
ps
.
roleId
});
if
(
role
==
null
)
{
throw
new
ApiError
(
meta
.
errors
.
noSuchRole
);
}
const
date
=
new
Date
();
await
this
.
role
sRepository
.
update
(
ps
.
role
Id
,
{
await
this
.
role
Service
.
update
(
role
,
{
updatedAt
:
date
,
name
:
ps
.
name
,
description
:
ps
.
description
,
...
...
@@ -91,9 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
canEditMembersByModerator
:
ps
.
canEditMembersByModerator
,
displayOrder
:
ps
.
displayOrder
,
policies
:
ps
.
policies
,
});
const
updated
=
await
this
.
rolesRepository
.
findOneByOrFail
({
id
:
ps
.
roleId
});
this
.
globalEventService
.
publishInternalEvent
(
'
roleUpdated
'
,
updated
);
},
me
);
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment