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
5f7fc54e
Verified
Commit
5f7fc54e
authored
1 year ago
by
Mar0xy
Browse files
Options
Downloads
Patches
Plain Diff
upd: delete emoji file from drive on emoji deletion
parent
5f3754f9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/backend/src/core/CustomEmojiService.ts
+18
-1
18 additions, 1 deletion
packages/backend/src/core/CustomEmojiService.ts
with
18 additions
and
1 deletion
packages/backend/src/core/CustomEmojiService.ts
+
18
−
1
View file @
5f7fc54e
...
...
@@ -12,7 +12,7 @@ import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
import
{
GlobalEventService
}
from
'
@/core/GlobalEventService.js
'
;
import
type
{
MiDriveFile
}
from
'
@/models/DriveFile.js
'
;
import
type
{
MiEmoji
}
from
'
@/models/Emoji.js
'
;
import
type
{
EmojisRepository
,
MiRole
,
MiUser
}
from
'
@/models/_.js
'
;
import
type
{
DriveFilesRepository
,
EmojisRepository
,
MiRole
,
MiUser
}
from
'
@/models/_.js
'
;
import
{
bindThis
}
from
'
@/decorators.js
'
;
import
{
MemoryKVCache
,
RedisSingleCache
}
from
'
@/misc/cache.js
'
;
import
{
UtilityService
}
from
'
@/core/UtilityService.js
'
;
...
...
@@ -20,6 +20,7 @@ import { query } from '@/misc/prelude/url.js';
import
type
{
Serialized
}
from
'
@/types.js
'
;
import
{
ModerationLogService
}
from
'
@/core/ModerationLogService.js
'
;
import
type
{
Config
}
from
'
@/config.js
'
;
import
{
DriveService
}
from
'
./DriveService.js
'
;
const
parseEmojiStrRegexp
=
/^
(\w
+
)(?:
@
([\w
.-
]
+
))?
$/
;
...
...
@@ -38,11 +39,15 @@ export class CustomEmojiService implements OnApplicationShutdown {
@
Inject
(
DI
.
emojisRepository
)
private
emojisRepository
:
EmojisRepository
,
@
Inject
(
DI
.
driveFilesRepository
)
private
driveFilesRepository
:
DriveFilesRepository
,
private
utilityService
:
UtilityService
,
private
idService
:
IdService
,
private
emojiEntityService
:
EmojiEntityService
,
private
moderationLogService
:
ModerationLogService
,
private
globalEventService
:
GlobalEventService
,
private
driveService
:
DriveService
,
)
{
this
.
cache
=
new
MemoryKVCache
<
MiEmoji
|
null
>
(
1000
*
60
*
60
*
12
);
...
...
@@ -259,6 +264,12 @@ export class CustomEmojiService implements OnApplicationShutdown {
this
.
localEmojisCache
.
refresh
();
const
file
=
await
this
.
driveFilesRepository
.
findOneBy
({
url
:
emoji
.
originalUrl
,
userHost
:
emoji
.
host
?
emoji
.
host
:
IsNull
()
});
if
(
file
)
{
await
this
.
driveService
.
deleteFile
(
file
,
false
,
moderator
?
moderator
:
undefined
);
}
this
.
globalEventService
.
publishBroadcastStream
(
'
emojiDeleted
'
,
{
emojis
:
[
await
this
.
emojiEntityService
.
packDetailed
(
emoji
)],
});
...
...
@@ -280,6 +291,12 @@ export class CustomEmojiService implements OnApplicationShutdown {
for
(
const
emoji
of
emojis
)
{
await
this
.
emojisRepository
.
delete
(
emoji
.
id
);
const
file
=
await
this
.
driveFilesRepository
.
findOneBy
({
url
:
emoji
.
originalUrl
,
userHost
:
emoji
.
host
?
emoji
.
host
:
IsNull
()
});
if
(
file
)
{
await
this
.
driveService
.
deleteFile
(
file
,
false
,
moderator
?
moderator
:
undefined
);
}
if
(
moderator
)
{
this
.
moderationLogService
.
log
(
moderator
,
'
deleteCustomEmoji
'
,
{
emojiId
:
emoji
.
id
,
...
...
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