Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
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
Dima Krasner
Sharkey
Commits
8968bfd3
Unverified
Commit
8968bfd3
authored
1 year ago
by
Camilla Ett
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(backend): カスタム絵文字のインポート時の動作を修正 (#12360)
Co-authored-by:
syuilo
<
Syuilotan@yahoo.co.jp
>
parent
c190b720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/server/api/endpoints/admin/emoji/copy.ts
+21
-21
21 additions, 21 deletions
...ages/backend/src/server/api/endpoints/admin/emoji/copy.ts
packages/frontend/src/pages/custom-emojis-manager.vue
+2
-2
2 additions, 2 deletions
packages/frontend/src/pages/custom-emojis-manager.vue
with
23 additions
and
23 deletions
packages/backend/src/server/api/endpoints/admin/emoji/copy.ts
+
21
−
21
View file @
8968bfd3
...
...
@@ -6,11 +6,10 @@
import
{
Inject
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
Endpoint
}
from
'
@/server/api/endpoint-base.js
'
;
import
type
{
EmojisRepository
}
from
'
@/models/_.js
'
;
import
{
IdService
}
from
'
@/core/IdService.js
'
;
import
type
{
MiDriveFile
}
from
'
@/models/DriveFile.js
'
;
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
{
DriveService
}
from
'
@/core/DriveService.js
'
;
import
{
GlobalEvent
Service
}
from
'
@/core/
GlobalEvent
Service.js
'
;
import
{
CustomEmoji
Service
}
from
'
@/core/
CustomEmoji
Service.js
'
;
import
{
EmojiEntityService
}
from
'
@/core/entities/EmojiEntityService.js
'
;
import
{
ApiError
}
from
'
../../../error.js
'
;
...
...
@@ -26,6 +25,11 @@ export const meta = {
code
:
'
NO_SUCH_EMOJI
'
,
id
:
'
e2785b66-dca3-4087-9cac-b93c541cc425
'
,
},
duplicateName
:
{
message
:
'
Duplicate name.
'
,
code
:
'
DUPLICATE_NAME
'
,
id
:
'
f7a3462c-4e6e-4069-8421-b9bd4f4c3975
'
,
},
},
res
:
{
...
...
@@ -56,15 +60,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
constructor
(
@
Inject
(
DI
.
emojisRepository
)
private
emojisRepository
:
EmojisRepository
,
private
emojiEntityService
:
EmojiEntityService
,
private
idService
:
IdService
,
private
globalEventService
:
GlobalEventService
,
private
customEmojiService
:
CustomEmojiService
,
private
driveService
:
DriveService
,
)
{
super
(
meta
,
paramDef
,
async
(
ps
,
me
)
=>
{
const
emoji
=
await
this
.
emojisRepository
.
findOneBy
({
id
:
ps
.
emojiId
});
if
(
emoji
==
null
)
{
throw
new
ApiError
(
meta
.
errors
.
noSuchEmoji
);
}
...
...
@@ -75,28 +76,27 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
// Create file
driveFile
=
await
this
.
driveService
.
uploadFromUrl
({
url
:
emoji
.
originalUrl
,
user
:
null
,
force
:
true
});
}
catch
(
e
)
{
// TODO: need to return Drive Error
throw
new
ApiError
();
}
const
copied
=
await
this
.
emojisRepository
.
insert
({
id
:
this
.
idService
.
gen
(),
updatedAt
:
new
Date
(),
// Duplication Check
const
isDuplicate
=
await
this
.
customEmojiService
.
checkDuplicate
(
emoji
.
name
);
if
(
isDuplicate
)
throw
new
ApiError
(
meta
.
errors
.
duplicateName
);
const
addedEmoji
=
await
this
.
customEmojiService
.
add
({
driveFile
,
name
:
emoji
.
name
,
category
:
emoji
.
category
,
aliases
:
emoji
.
aliases
,
host
:
null
,
aliases
:
[],
originalUrl
:
driveFile
.
url
,
publicUrl
:
driveFile
.
webpublicUrl
??
driveFile
.
url
,
type
:
driveFile
.
webpublicType
??
driveFile
.
type
,
license
:
emoji
.
license
,
}).
then
(
x
=>
this
.
emojisRepository
.
findOneByOrFail
(
x
.
identifiers
[
0
]));
this
.
globalEventService
.
publishBroadcastStream
(
'
emojiAdded
'
,
{
emoji
:
await
this
.
emojiEntityService
.
packDetailed
(
copied
.
id
),
});
isSensitive
:
emoji
.
isSensitive
,
localOnly
:
emoji
.
localOnly
,
roleIdsThatCanBeUsedThisEmojiAsReaction
:
emoji
.
roleIdsThatCanBeUsedThisEmojiAsReaction
,
},
me
);
return
{
id
:
copied
.
id
,
};
return
this
.
emojiEntityService
.
packDetailed
(
addedEmoji
);
});
}
}
This diff is collapsed.
Click to expand it.
packages/frontend/src/pages/custom-emojis-manager.vue
+
2
−
2
View file @
8968bfd3
...
...
@@ -155,7 +155,7 @@ const edit = (emoji) => {
},
'
closed
'
);
};
const
im
=
(
emoji
)
=>
{
const
im
portEmoji
=
(
emoji
)
=>
{
os
.
apiWithDialog
(
'
admin/emoji/copy
'
,
{
emojiId
:
emoji
.
id
,
});
...
...
@@ -168,7 +168,7 @@ const remoteMenu = (emoji, ev: MouseEvent) => {
},
{
text
:
i18n
.
ts
.
import
,
icon
:
'
ti ti-plus
'
,
action
:
()
=>
{
im
(
emoji
);
},
action
:
()
=>
{
im
portEmoji
(
emoji
);
},
}],
ev
.
currentTarget
??
ev
.
target
);
};
...
...
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