Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net committed Jan 10, 2025
1 parent fefa671 commit c7a9b5d
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12671,6 +12671,10 @@ export interface Locale extends ILocale {
* 条件付き
*/
"conditional": string;
/**
* 絵文字ベース
*/
"isBasedOn": string;
};
}
declare const locales: {
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3384,3 +3384,4 @@ _emoji:
allow: "許可"
deny: "禁止"
conditional: "条件付き"
isBasedOn: "絵文字ベース"
129 changes: 124 additions & 5 deletions packages/backend/test-federation/test/emoji.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('Emoji', () => {
credentials: 'omit',
cache: 'no-cache',
});
console.log(await res.json());
strictEqual((await res.json()).code, 'NOT_ALLOWED')

Check failure on line 213 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Missing semicolon
});
test('コピー拒否の絵文字をコピーできない(steal)', async () => {
const emoji = await addCustomEmoji('a.test', {
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('Emoji', () => {
credentials: 'omit',
cache: 'no-cache',
});
console.log(await res.json());
strictEqual((await res.json()).code, 'NOT_ALLOWED')

Check failure on line 249 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Missing semicolon
});

test('コピー許可の絵文字をコピーできる(copy)', async () => {
Expand Down Expand Up @@ -331,7 +331,8 @@ describe('Emoji', () => {
isBasedOn: 'isBasedOn',
}), JSON.stringify(res));
});
test('条件付きの絵文字をコピーできない', async () => {

test('条件付きの絵文字をコピーできない(copy)', async () => {
const emoji = await addCustomEmoji('a.test', {
aliases: ['a', 'b', 'c'],
license: 'license',
Expand Down Expand Up @@ -367,7 +368,125 @@ describe('Emoji', () => {
credentials: 'omit',
cache: 'no-cache',
});
console.log(await res.json());
strictEqual((await res.json()).code, 'SEE_USAGEINFOMATION_OR_LICENSE')
strictEqual((await res.json()).code, 'SEE_USAGEINFOMATION_OR_LICENSE')

Check failure on line 371 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Missing semicolon
});
test('条件付きの絵文字をコピーできない(steal)', async () => {
const emoji = await addCustomEmoji('a.test', {
aliases: ['a', 'b', 'c'],
license: 'license',
category: 'category',
copyPermission: 'conditional',
usageInfo: 'usageInfo',
author: '@[email protected]',
description: 'description',
isBasedOn: 'isBasedOn',
});
await alice.client.request('notes/create', { text: `I love :${emoji.name}:` });
await sleep();

const notes = await bob.client.request('notes/timeline', {});
const noteInB = notes[0];

strictEqual(noteInB.text, `I love \u200b:${emoji.name}:\u200b`);
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
let res = await fetch(`https://b.test/api/admin/emoji/steal`, {

Check failure on line 394 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

'res' is never reassigned. Use 'const' instead
method: 'POST',
body: JSON.stringify({
name: emoji.name,
host: 'a.test',
i: bAdmin.client.credential,
}),
headers: {
'Content-Type': 'application/json',
},
credentials: 'omit',
cache: 'no-cache',
});
strictEqual((await res.json()).code, 'SEE_USAGEINFOMATION_OR_LICENSE')

Check failure on line 407 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Missing semicolon
});
test('条件付きの絵文字をコピーできる(copy)', async () => {
const emoji = await addCustomEmoji('a.test', {
aliases: ['a', 'b', 'c'],
license: 'license',
category: 'category',
copyPermission: 'allow',
usageInfo: 'usageInfo',
author: '@[email protected]',
description: 'description',
isBasedOn: 'isBasedOn',
});
await alice.client.request('notes/create', { text: `I love :${emoji.name}:` });
await sleep();

const notes = await bob.client.request('notes/timeline', {});
const noteInB = notes[0];

strictEqual(noteInB.text, `I love \u200b:${emoji.name}:\u200b`);
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
// @ts-expect-error anyで警告が出るため
const emojiId = (await bAdmin.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = await bAdmin.client.request('admin/emoji/copy', { emojiId: emojiId, usageInfoReaded: true });
strictEqual(JSON.stringify({
id: res.id,
aliases: emoji.aliases,
name: emoji.name,
category: emoji.category,
host: null,
url: res.url,
license: emoji.license,
isSensitive: false,
localOnly: false,
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
copyPermission: emoji.copyPermission,
usageInfo: emoji.usageInfo,
author: emoji.author,
description: emoji.description,
isBasedOn: 'isBasedOn',
}), JSON.stringify(res));
});
test('条件付きの絵文字をコピーできる(steal)', async () => {
const emoji = await addCustomEmoji('a.test', {
aliases: ['a', 'b', 'c'],
license: 'license',
category: 'category',
copyPermission: 'allow',
usageInfo: 'usageInfo',
author: '@[email protected]',
description: 'description',
isBasedOn: 'isBasedOn',
});
await alice.client.request('notes/create', { text: `I love :${emoji.name}:` });
await sleep();

const notes = await bob.client.request('notes/timeline', {});
const noteInB = notes[0];

strictEqual(noteInB.text, `I love \u200b:${emoji.name}:\u200b`);
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const res = await bAdmin.client.request('admin/emoji/steal', { name: emoji.name, host: 'a.test', usageInfoReaded: true });
strictEqual(JSON.stringify({
id: res.id,
aliases: emoji.aliases,
name: emoji.name,
category: emoji.category,
host: null,
url: res.url,
license: emoji.license,
isSensitive: false,
localOnly: false,
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
copyPermission: emoji.copyPermission,
usageInfo: emoji.usageInfo,
author: emoji.author,
description: emoji.description,
isBasedOn: 'isBasedOn',
}), JSON.stringify(res));
});

Check failure on line 490 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Block must not be padded by blank lines

});
5 changes: 5 additions & 0 deletions packages/frontend/src/pages/emoji-edit-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="usageInfo">
<template #label>{{ i18n.ts._emoji.usageInfo }}</template>
</MkInput>
<MkInput v-model="isBasedOn">
<template #label>{{ i18n.ts._emoji.isBasedOn }}</template>
</MkInput>
<MkTextarea v-model="license" :mfmAutocomplete="true">
<template #label>{{ i18n.ts.license }}</template>
</MkTextarea>
Expand Down Expand Up @@ -125,6 +128,7 @@ const localOnly = ref(props.emoji ? props.emoji.localOnly : false);
const description = ref<string>(props.emoji ? (props.emoji.description ?? '') : '');
const author = ref<string>(props.emoji ? (props.emoji.author ?? '') : '');
const usageInfo = ref<string>(props.emoji ? (props.emoji.usageInfo ?? '') : '');
const isBasedOn = ref<string>(props.emoji ? (props.emoji.isBasedOn ?? '') : '');
const copyPermission = ref<string>(props.emoji ? (props.emoji.copyPermission ?? null ) : 'allow');
const roleIdsThatCanBeUsedThisEmojiAsReaction = ref(props.emoji ? props.emoji.roleIdsThatCanBeUsedThisEmojiAsReaction : []);
const rolesThatCanBeUsedThisEmojiAsReaction = ref<Misskey.entities.Role[]>([]);
Expand Down Expand Up @@ -176,6 +180,7 @@ async function done() {
description: description.value,
author: author.value,
usageInfo: usageInfo.value,
isBasedOn: isBasedOn.value,
copyPermission: copyPermission.value,
roleIdsThatCanBeUsedThisEmojiAsReaction: rolesThatCanBeUsedThisEmojiAsReaction.value.map(x => x.id),
};
Expand Down

0 comments on commit c7a9b5d

Please sign in to comment.