-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1752 from h3poteto/iss-1717
refs #1717 Fix custom emoji for Misskey
- Loading branch information
Showing
9 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import generator, { MegalodonInterface } from 'megalodon' | ||
|
||
declare var process: { | ||
env: { | ||
MISSKEY_ACCESS_TOKEN: string | ||
} | ||
} | ||
|
||
const BASE_URL: string = 'https://misskey.io' | ||
|
||
const access_token: string = process.env.MISSKEY_ACCESS_TOKEN | ||
|
||
const client: MegalodonInterface = generator('misskey', BASE_URL, access_token) | ||
|
||
client | ||
.getInstanceCustomEmojis() | ||
.then(res => console.log(res.data)) | ||
.catch(err => console.error(err)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import generator, { MegalodonInterface } from 'megalodon' | ||
|
||
declare var process: { | ||
env: { | ||
MISSKEY_ACCESS_TOKEN: string | ||
} | ||
} | ||
|
||
const BASE_URL: string = 'https://misskey.io' | ||
|
||
const access_token: string = process.env.MISSKEY_ACCESS_TOKEN | ||
|
||
const client: MegalodonInterface = generator('misskey', BASE_URL, access_token) | ||
|
||
client | ||
.getStatus('9fjp2aknrm') | ||
.then(res => console.log(res.data)) | ||
.catch(err => console.error(err)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace MisskeyEntity { | ||
export type Emoji = { | ||
name: string | ||
host: string | null | ||
url: string | ||
aliases: Array<string> | ||
category: string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,7 @@ describe('api_client', () => { | |
renoteCount: 0, | ||
repliesCount: 0, | ||
reactions: {}, | ||
reactionEmojis: {}, | ||
emojis: [], | ||
fileIds: [], | ||
files: [], | ||
|
@@ -216,6 +217,7 @@ describe('api_client', () => { | |
renoteCount: 0, | ||
repliesCount: 0, | ||
reactions: {}, | ||
reactionEmojis: {}, | ||
emojis: [], | ||
fileIds: [], | ||
files: [], | ||
|
@@ -227,5 +229,55 @@ describe('api_client', () => { | |
expect(megalodonStatus.content).toEqual(content) | ||
}) | ||
}) | ||
describe('emoji reaction', () => { | ||
it('reactionEmojis should be parsed', () => { | ||
const plainContent = 'hoge\nfuga\nfuga' | ||
const note: MisskeyEntity.Note = { | ||
id: '1', | ||
createdAt: '2021-02-01T01:49:29', | ||
userId: '1', | ||
user: user, | ||
text: plainContent, | ||
cw: null, | ||
visibility: 'public', | ||
renoteCount: 0, | ||
repliesCount: 0, | ||
reactions: { | ||
':example1@.:': 1, | ||
':[email protected]:': 2 | ||
}, | ||
reactionEmojis: { | ||
'[email protected]': 'https://example.com/emoji.png' | ||
}, | ||
emojis: [], | ||
fileIds: [], | ||
files: [], | ||
replyId: null, | ||
renoteId: null | ||
} | ||
const megalodonStatus = MisskeyAPI.Converter.note(note) | ||
expect(megalodonStatus.emojis).toEqual([ | ||
{ | ||
shortcode: '[email protected]', | ||
static_url: 'https://example.com/emoji.png', | ||
url: 'https://example.com/emoji.png', | ||
visible_in_picker: true, | ||
category: '' | ||
} | ||
]) | ||
expect(megalodonStatus.emoji_reactions).toEqual([ | ||
{ | ||
count: 1, | ||
me: false, | ||
name: ':example1@.:' | ||
}, | ||
{ | ||
count: 2, | ||
me: false, | ||
name: ':[email protected]:' | ||
} | ||
]) | ||
}) | ||
}) | ||
}) | ||
}) |