forked from FoundKeyGang/FoundKey
server: fix/document strange requirements for emoji packs
The change in the emoji export logic should fix the case where emoji packs exported with Foundkey should be used in any other Misskey fork. I've opted not to change the import logic and instead document the strange behaviour because it would also not be accepted by Misskey.
This commit is contained in:
parent
3968a6ca07
commit
ada577bde6
2 changed files with 6 additions and 5 deletions
|
@ -74,6 +74,9 @@ The fields of `Meta` are currently not used or checked when importing emoji, exc
|
|||
For each `Emoji`:
|
||||
- `downloaded`: should always be true. If the field is missing or not truthy, the emoji will not be imported.
|
||||
- `fileName`: name of the image file inside the packed file.
|
||||
The filename has to match the following ECMAScript RegExp: `/^[a-zA-Z0-9_]+?([a-zA-Z0-9\.]+)?$/`
|
||||
(i.e. composed of latin letters, digits, underscores or dots, not starting with a dot and not ending with an underscore)
|
||||
If the file does not match this RegExp, the respective emoji will not be imported!
|
||||
- `emoji`: data associated with the emoji as it was stored in the database. Currently most of these fields are
|
||||
not even checked for existence. The following are currently used:
|
||||
- `name`: name of the emoji for the user, e.g. `blobfox` if a user should type in `:blobfox:` to get the emoji.
|
||||
|
|
|
@ -58,12 +58,10 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
|||
});
|
||||
|
||||
for (const emoji of customEmojis) {
|
||||
if (!/^[a-zA-Z0-9_]+$/.test(emoji.name)) {
|
||||
this.logger.error(`invalid emoji name: ${emoji.name}, skipping in emoji export`);
|
||||
continue;
|
||||
}
|
||||
const ext = mime.extension(emoji.type);
|
||||
const fileName = emoji.name + (ext ? '.' + ext : '');
|
||||
// there are some restrictions on file names, so to be safe the files are
|
||||
// named after their database id instead of the actual emoji name
|
||||
const fileName = emoji.id + (ext ? '.' + ext : '');
|
||||
const emojiPath = path + '/' + fileName;
|
||||
fs.writeFileSync(emojiPath, '', 'binary');
|
||||
let downloaded = false;
|
||||
|
|
Loading…
Reference in a new issue