mirror of
https://example.com
synced 2024-11-24 11:16:41 +09:00
chore: upgrade dependencies & remove tests from megalodon
This commit is contained in:
parent
3ba266448c
commit
8dc96a3195
13 changed files with 608 additions and 2633 deletions
10
package.json
10
package.json
|
@ -9,7 +9,7 @@
|
|||
"engines": {
|
||||
"node": ">= 18.17.0"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.0",
|
||||
"packageManager": "pnpm@8.15.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"rebuild": "pnpm run clean && pnpm run build",
|
||||
|
@ -34,8 +34,8 @@
|
|||
"cleanall": "pnpm run clean-all"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bull-board/api": "5.13.0",
|
||||
"@bull-board/ui": "5.13.0",
|
||||
"@bull-board/api": "5.14.0",
|
||||
"@bull-board/ui": "5.14.0",
|
||||
"@napi-rs/cli": "2.18.0",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-cssnano": "2.1.3",
|
||||
|
@ -49,9 +49,9 @@
|
|||
"@biomejs/cli-darwin-x64": "1.5.3",
|
||||
"@biomejs/cli-linux-arm64": "1.5.3",
|
||||
"@biomejs/cli-linux-x64": "1.5.3",
|
||||
"@types/node": "20.11.6",
|
||||
"@types/node": "20.11.13",
|
||||
"execa": "8.0.1",
|
||||
"pnpm": "8.15.0",
|
||||
"pnpm": "8.15.1",
|
||||
"typescript": "5.3.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ crate-type = ["cdylib", "lib"]
|
|||
[dependencies]
|
||||
async-trait = "0.1.77"
|
||||
cfg-if = "1.0.0"
|
||||
chrono = "0.4.32"
|
||||
chrono = "0.4.33"
|
||||
cuid2 = "0.1.2"
|
||||
idna = "0.5.0"
|
||||
jsonschema = "0.17.1"
|
||||
|
@ -23,16 +23,16 @@ rand = "0.8.5"
|
|||
regex = "1.10.3"
|
||||
schemars = { version = "0.8.16", features = ["chrono"] }
|
||||
sea-orm = { version = "0.12.12", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
serde = { version = "1.0.195", features = ["derive"] }
|
||||
serde_json = "1.0.111"
|
||||
serde_yaml = "0.9.30"
|
||||
serde = { version = "1.0.196", features = ["derive"] }
|
||||
serde_json = "1.0.113"
|
||||
serde_yaml = "0.9.31"
|
||||
thiserror = "1.0.56"
|
||||
tokio = { version = "1.35.1", features = ["full"] }
|
||||
url = "2.5.0"
|
||||
|
||||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
||||
napi = { version = "2.14.4", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
|
||||
napi-derive = { version = "2.14.6", optional = true }
|
||||
napi = { version = "2.15.0", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
|
||||
napi-derive = { version = "2.15.0", optional = true }
|
||||
basen = "0.1.0"
|
||||
urlencoding = "2.1.3"
|
||||
argon2 = "0.5.3"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "2.18.0",
|
||||
"ava": "6.1.0"
|
||||
"ava": "6.1.1"
|
||||
},
|
||||
"ava": {
|
||||
"timeout": "3m"
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
"@swc/core-android-arm64": "1.3.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bull-board/api": "5.13.0",
|
||||
"@bull-board/koa": "5.13.0",
|
||||
"@bull-board/ui": "5.13.0",
|
||||
"@bull-board/api": "5.14.0",
|
||||
"@bull-board/koa": "5.14.0",
|
||||
"@bull-board/ui": "5.14.0",
|
||||
"@discordapp/twemoji": "^15.0.2",
|
||||
"@koa/cors": "5.0.0",
|
||||
"@koa/multer": "3.0.2",
|
||||
"@koa/router": "12.0.1",
|
||||
"@ladjs/koa-views": "9.0.0",
|
||||
"@peertube/http-signature": "1.7.0",
|
||||
"@redocly/openapi-core": "1.7.0",
|
||||
"@redocly/openapi-core": "1.8.1",
|
||||
"@sinonjs/fake-timers": "11.2.2",
|
||||
"@twemoji/parser": "^15.0.0",
|
||||
"adm-zip": "^0.5.10",
|
||||
"ajv": "8.12.0",
|
||||
"archiver": "6.0.1",
|
||||
"aws-sdk": "2.1542.0",
|
||||
"axios": "1.6.5",
|
||||
"aws-sdk": "2.1547.0",
|
||||
"axios": "1.6.7",
|
||||
"backend-rs": "workspace:*",
|
||||
"blurhash": "2.0.5",
|
||||
"bull": "4.12.2",
|
||||
|
@ -49,15 +49,15 @@
|
|||
"date-fns": "3.3.1",
|
||||
"decompress": "4.2.1",
|
||||
"deep-email-validator": "0.1.21",
|
||||
"deepl-node": "1.11.0",
|
||||
"deepl-node": "1.11.1",
|
||||
"escape-regexp": "0.0.1",
|
||||
"feed": "4.2.2",
|
||||
"file-type": "19.0.0",
|
||||
"fluent-ffmpeg": "2.1.2",
|
||||
"firefish-js": "workspace:*",
|
||||
"got": "14.0.0",
|
||||
"got": "14.1.0",
|
||||
"gunzip-maybe": "1.4.2",
|
||||
"happy-dom": "13.3.1",
|
||||
"happy-dom": "13.3.8",
|
||||
"hpagent": "1.2.0",
|
||||
"ioredis": "5.3.2",
|
||||
"ip-cidr": "4.0.0",
|
||||
|
@ -89,7 +89,7 @@
|
|||
"otpauth": "9.2.2",
|
||||
"parse5": "7.1.2",
|
||||
"pg": "8.11.3",
|
||||
"private-ip": "3.0.1",
|
||||
"private-ip": "3.0.2",
|
||||
"probe-image-size": "7.2.3",
|
||||
"promise-limit": "2.7.0",
|
||||
"punycode": "2.3.1",
|
||||
|
@ -114,7 +114,7 @@
|
|||
"tesseract.js": "5.0.4",
|
||||
"tinycolor2": "1.6.0",
|
||||
"tmp": "0.2.1",
|
||||
"typeorm": "0.3.19",
|
||||
"typeorm": "0.3.20",
|
||||
"ulid": "2.3.0",
|
||||
"uuid": "9.0.1",
|
||||
"web-push": "3.6.7",
|
||||
|
@ -123,7 +123,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "0.1.65",
|
||||
"@swc/core": "1.3.105",
|
||||
"@swc/core": "1.3.107",
|
||||
"@types/adm-zip": "0.5.5",
|
||||
"@types/escape-regexp": "0.0.3",
|
||||
"@types/fluent-ffmpeg": "2.1.24",
|
||||
|
@ -140,12 +140,12 @@
|
|||
"@types/koa__cors": "5.0.0",
|
||||
"@types/koa__multer": "2.0.7",
|
||||
"@types/koa__router": "12.0.4",
|
||||
"@types/node": "20.11.6",
|
||||
"@types/node": "20.11.13",
|
||||
"@types/node-fetch": "2.6.11",
|
||||
"@types/nodemailer": "6.4.14",
|
||||
"@types/oauth": "0.9.4",
|
||||
"@types/opencc-js": "1.0.3",
|
||||
"@types/pg": "8.10.9",
|
||||
"@types/pg": "8.11.0",
|
||||
"@types/probe-image-size": "7.2.4",
|
||||
"@types/pug": "2.0.10",
|
||||
"@types/punycode": "2.1.3",
|
||||
|
@ -160,7 +160,7 @@
|
|||
"@types/syslog-pro": "1.0.3",
|
||||
"@types/tinycolor2": "1.4.6",
|
||||
"@types/tmp": "0.2.6",
|
||||
"@types/uuid": "9.0.7",
|
||||
"@types/uuid": "9.0.8",
|
||||
"@types/web-push": "3.6.3",
|
||||
"@types/websocket": "1.0.10",
|
||||
"@types/ws": "8.5.10",
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"@types/textarea-caret": "3.0.3",
|
||||
"@types/throttle-debounce": "5.0.2",
|
||||
"@types/tinycolor2": "1.4.6",
|
||||
"@types/uuid": "9.0.7",
|
||||
"@types/uuid": "9.0.8",
|
||||
"@vitejs/plugin-vue": "5.0.3",
|
||||
"@vue/runtime-core": "3.4.15",
|
||||
"autobind-decorator": "2.4.0",
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "0.1.65",
|
||||
"@swc/core": "1.3.105",
|
||||
"@swc/core": "1.3.107",
|
||||
"@swc/types": "0.1.5",
|
||||
"@types/node": "20.11.6",
|
||||
"@types/node": "20.11.13",
|
||||
"ts-node": "10.9.2",
|
||||
"tsd": "0.30.4",
|
||||
"typescript": "5.3.3"
|
||||
|
|
|
@ -8,76 +8,45 @@
|
|||
"build:debug": "pnpm run build",
|
||||
"lint": "pnpm biome check **/*.ts --apply",
|
||||
"format": "pnpm biome format --write src/**/*.ts",
|
||||
"doc": "typedoc --out ../docs ./src",
|
||||
"test": "NODE_ENV=test jest -u --maxWorkers=3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"js"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"^@/(.+)": "<rootDir>/src/$1",
|
||||
"^~/(.+)": "<rootDir>/$1"
|
||||
},
|
||||
"testMatch": [
|
||||
"**/test/**/*.spec.ts"
|
||||
],
|
||||
"preset": "ts-jest/presets/default",
|
||||
"transform": {
|
||||
"^.+\\.(ts|tsx)$": "ts-jest"
|
||||
},
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"tsconfig": "tsconfig.json"
|
||||
}
|
||||
},
|
||||
"testEnvironment": "node"
|
||||
"doc": "typedoc --out ../docs ./src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/oauth": "^0.9.0",
|
||||
"@types/ws": "^8.5.4",
|
||||
"axios": "1.2.2",
|
||||
"dayjs": "^1.11.7",
|
||||
"@types/oauth": "^0.9.4",
|
||||
"@types/ws": "^8.5.10",
|
||||
"axios": "1.6.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"form-data": "^4.0.0",
|
||||
"https-proxy-agent": "^5.0.1",
|
||||
"oauth": "^0.10.0",
|
||||
"object-assign-deep": "^0.4.0",
|
||||
"parse-link-header": "^2.0.0",
|
||||
"socks-proxy-agent": "^7.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
"ws": "8.12.0",
|
||||
"async-lock": "1.4.0"
|
||||
"uuid": "^9.0.1",
|
||||
"ws": "8.16.0",
|
||||
"async-lock": "1.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/core-js": "^2.5.0",
|
||||
"@types/form-data": "^2.5.0",
|
||||
"@types/jest": "^29.4.0",
|
||||
"@types/object-assign-deep": "^0.4.0",
|
||||
"@types/parse-link-header": "^2.0.0",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/node": "18.11.18",
|
||||
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
||||
"@typescript-eslint/parser": "^5.49.0",
|
||||
"@types/async-lock": "1.4.0",
|
||||
"eslint": "^8.32.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"@types/core-js": "^2.5.8",
|
||||
"@types/object-assign-deep": "^0.4.3",
|
||||
"@types/parse-link-header": "^2.0.3",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@types/node": "20.11.13",
|
||||
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
||||
"@typescript-eslint/parser": "^6.20.0",
|
||||
"@types/async-lock": "1.4.2",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-config-standard": "^17.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"jest": "^29.4.0",
|
||||
"jest-worker": "^29.4.0",
|
||||
"lodash": "^4.17.14",
|
||||
"prettier": "^2.8.3",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typedoc": "^0.23.24",
|
||||
"typescript": "4.9.4"
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": "^3.2.4",
|
||||
"typedoc": "^0.25.7",
|
||||
"typescript": "5.3.3"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
"lib": "lib"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import { detector } from '../../src/index'
|
||||
|
||||
describe('detector', () => {
|
||||
describe('mastodon', () => {
|
||||
const url = 'https://fedibird.com'
|
||||
it('should be mastodon', async () => {
|
||||
const mastodon = await detector(url)
|
||||
expect(mastodon).toEqual('mastodon')
|
||||
})
|
||||
})
|
||||
|
||||
describe('pleroma', () => {
|
||||
const url = 'https://pleroma.soykaf.com'
|
||||
it('should be pleroma', async () => {
|
||||
const pleroma = await detector(url)
|
||||
expect(pleroma).toEqual('pleroma')
|
||||
})
|
||||
})
|
||||
|
||||
describe('misskey', () => {
|
||||
const url = 'https://misskey.io'
|
||||
it('should be misskey', async () => {
|
||||
const misskey = await detector(url)
|
||||
expect(misskey).toEqual('misskey')
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,204 +0,0 @@
|
|||
import MisskeyEntity from '@/misskey/entity'
|
||||
import MisskeyNotificationType from '@/misskey/notification'
|
||||
import Misskey from '@/misskey'
|
||||
import MegalodonNotificationType from '@/notification'
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const user: MisskeyEntity.User = {
|
||||
id: '1',
|
||||
name: 'test_user',
|
||||
username: 'TestUser',
|
||||
host: 'misskey.io',
|
||||
avatarUrl: 'https://example.com/icon.png',
|
||||
avatarColor: '#000000',
|
||||
emojis: []
|
||||
}
|
||||
|
||||
const note: MisskeyEntity.Note = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: '1',
|
||||
user: user,
|
||||
text: 'hogehoge',
|
||||
cw: null,
|
||||
visibility: 'public',
|
||||
renoteCount: 0,
|
||||
repliesCount: 0,
|
||||
reactions: {},
|
||||
emojis: [],
|
||||
fileIds: [],
|
||||
files: [],
|
||||
replyId: null,
|
||||
renoteId: null
|
||||
}
|
||||
|
||||
const follow: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Follow
|
||||
}
|
||||
|
||||
const mention: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Mention,
|
||||
note: note
|
||||
}
|
||||
|
||||
const reply: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Reply,
|
||||
note: note
|
||||
}
|
||||
|
||||
const renote: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Renote,
|
||||
note: note
|
||||
}
|
||||
|
||||
const quote: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Quote,
|
||||
note: note
|
||||
}
|
||||
|
||||
const reaction: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.Reaction,
|
||||
note: note,
|
||||
reaction: '♥'
|
||||
}
|
||||
|
||||
const pollVote: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.PollEnded,
|
||||
note: note
|
||||
}
|
||||
|
||||
const receiveFollowRequest: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.ReceiveFollowRequest
|
||||
}
|
||||
|
||||
const followRequestAccepted: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.FollowRequestAccepted
|
||||
}
|
||||
|
||||
const groupInvited: MisskeyEntity.Notification = {
|
||||
id: '1',
|
||||
createdAt: '2021-02-01T01:49:29',
|
||||
userId: user.id,
|
||||
user: user,
|
||||
type: MisskeyNotificationType.GroupInvited
|
||||
}
|
||||
|
||||
;(axios.CancelToken.source as any).mockImplementation(() => {
|
||||
return {
|
||||
token: {
|
||||
throwIfRequested: () => {},
|
||||
promise: {
|
||||
then: () => {},
|
||||
catch: () => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe('getNotifications', () => {
|
||||
const client = new Misskey('http://localhost', 'sample token')
|
||||
const cases: Array<{ event: MisskeyEntity.Notification; expected: Entity.NotificationType; title: string }> = [
|
||||
{
|
||||
event: follow,
|
||||
expected: MegalodonNotificationType.Follow,
|
||||
title: 'follow'
|
||||
},
|
||||
{
|
||||
event: mention,
|
||||
expected: MegalodonNotificationType.Mention,
|
||||
title: 'mention'
|
||||
},
|
||||
{
|
||||
event: reply,
|
||||
expected: MegalodonNotificationType.Mention,
|
||||
title: 'reply'
|
||||
},
|
||||
{
|
||||
event: renote,
|
||||
expected: MegalodonNotificationType.Reblog,
|
||||
title: 'renote'
|
||||
},
|
||||
{
|
||||
event: quote,
|
||||
expected: MegalodonNotificationType.Reblog,
|
||||
title: 'quote'
|
||||
},
|
||||
{
|
||||
event: reaction,
|
||||
expected: MegalodonNotificationType.Reaction,
|
||||
title: 'reaction'
|
||||
},
|
||||
{
|
||||
event: pollVote,
|
||||
expected: MegalodonNotificationType.Poll,
|
||||
title: 'pollVote'
|
||||
},
|
||||
{
|
||||
event: receiveFollowRequest,
|
||||
expected: MegalodonNotificationType.FollowRequest,
|
||||
title: 'receiveFollowRequest'
|
||||
},
|
||||
{
|
||||
event: followRequestAccepted,
|
||||
expected: MegalodonNotificationType.Follow,
|
||||
title: 'followRequestAccepted'
|
||||
},
|
||||
{
|
||||
event: groupInvited,
|
||||
expected: MisskeyNotificationType.GroupInvited,
|
||||
title: 'groupInvited'
|
||||
}
|
||||
]
|
||||
cases.forEach(c => {
|
||||
it(`should be ${c.title} event`, async () => {
|
||||
const mockResponse: AxiosResponse<Array<MisskeyEntity.Notification>> = {
|
||||
data: [c.event],
|
||||
status: 200,
|
||||
statusText: '200OK',
|
||||
headers: {},
|
||||
config: {}
|
||||
}
|
||||
;(axios.post as any).mockResolvedValue(mockResponse)
|
||||
const res = await client.getNotifications()
|
||||
expect(res.data[0].type).toEqual(c.expected)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,233 +0,0 @@
|
|||
import MisskeyAPI from '@/misskey/api_client'
|
||||
import MegalodonEntity from '@/entity'
|
||||
import MisskeyEntity from '@/misskey/entity'
|
||||
import MegalodonNotificationType from '@/notification'
|
||||
import MisskeyNotificationType from '@/misskey/notification'
|
||||
|
||||
const user: MisskeyEntity.User = {
|
||||
id: '1',
|
||||
name: 'test_user',
|
||||
username: 'TestUser',
|
||||
host: 'misskey.io',
|
||||
avatarUrl: 'https://example.com/icon.png',
|
||||
avatarColor: '#000000',
|
||||
emojis: []
|
||||
}
|
||||
|
||||
const converter: MisskeyAPI.Converter = new MisskeyAPI.Converter("https://example.com")
|
||||
|
||||
describe('api_client', () => {
|
||||
describe('notification', () => {
|
||||
describe('encode', () => {
|
||||
it('megalodon notification type should be encoded to misskey notification type', () => {
|
||||
const cases: Array<{ src: MegalodonEntity.NotificationType; dist: MisskeyEntity.NotificationType }> = [
|
||||
{
|
||||
src: MegalodonNotificationType.Follow,
|
||||
dist: MisskeyNotificationType.Follow
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.Mention,
|
||||
dist: MisskeyNotificationType.Reply
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.Favourite,
|
||||
dist: MisskeyNotificationType.Reaction
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.Reaction,
|
||||
dist: MisskeyNotificationType.Reaction
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.Reblog,
|
||||
dist: MisskeyNotificationType.Renote
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.Poll,
|
||||
dist: MisskeyNotificationType.PollEnded
|
||||
},
|
||||
{
|
||||
src: MegalodonNotificationType.FollowRequest,
|
||||
dist: MisskeyNotificationType.ReceiveFollowRequest
|
||||
}
|
||||
]
|
||||
cases.forEach(c => {
|
||||
expect(converter.encodeNotificationType(c.src)).toEqual(c.dist)
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('decode', () => {
|
||||
it('misskey notification type should be decoded to megalodon notification type', () => {
|
||||
const cases: Array<{ src: MisskeyEntity.NotificationType; dist: MegalodonEntity.NotificationType }> = [
|
||||
{
|
||||
src: MisskeyNotificationType.Follow,
|
||||
dist: MegalodonNotificationType.Follow
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.Mention,
|
||||
dist: MegalodonNotificationType.Mention
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.Reply,
|
||||
dist: MegalodonNotificationType.Mention
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.Renote,
|
||||
dist: MegalodonNotificationType.Reblog
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.Quote,
|
||||
dist: MegalodonNotificationType.Reblog
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.Reaction,
|
||||
dist: MegalodonNotificationType.Reaction
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.PollEnded,
|
||||
dist: MegalodonNotificationType.Poll
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.ReceiveFollowRequest,
|
||||
dist: MegalodonNotificationType.FollowRequest
|
||||
},
|
||||
{
|
||||
src: MisskeyNotificationType.FollowRequestAccepted,
|
||||
dist: MegalodonNotificationType.Follow
|
||||
}
|
||||
]
|
||||
cases.forEach(c => {
|
||||
expect(converter.decodeNotificationType(c.src)).toEqual(c.dist)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('reactions', () => {
|
||||
it('should be mapped', () => {
|
||||
const misskeyReactions = [
|
||||
{
|
||||
id: '1',
|
||||
createdAt: '2020-04-21T13:04:13.968Z',
|
||||
user: {
|
||||
id: '81u70uwsja',
|
||||
name: 'h3poteto',
|
||||
username: 'h3poteto',
|
||||
host: null,
|
||||
avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png',
|
||||
avatarColor: 'rgb(146,189,195)',
|
||||
emojis: []
|
||||
},
|
||||
type: '❤'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
createdAt: '2020-04-21T13:04:13.968Z',
|
||||
user: {
|
||||
id: '81u70uwsja',
|
||||
name: 'h3poteto',
|
||||
username: 'h3poteto',
|
||||
host: null,
|
||||
avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png',
|
||||
avatarColor: 'rgb(146,189,195)',
|
||||
emojis: []
|
||||
},
|
||||
type: '❤'
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
createdAt: '2020-04-21T13:04:13.968Z',
|
||||
user: {
|
||||
id: '81u70uwsja',
|
||||
name: 'h3poteto',
|
||||
username: 'h3poteto',
|
||||
host: null,
|
||||
avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png',
|
||||
avatarColor: 'rgb(146,189,195)',
|
||||
emojis: []
|
||||
},
|
||||
type: '☺'
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
createdAt: '2020-04-21T13:04:13.968Z',
|
||||
user: {
|
||||
id: '81u70uwsja',
|
||||
name: 'h3poteto',
|
||||
username: 'h3poteto',
|
||||
host: null,
|
||||
avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png',
|
||||
avatarColor: 'rgb(146,189,195)',
|
||||
emojis: []
|
||||
},
|
||||
type: '❤'
|
||||
}
|
||||
]
|
||||
|
||||
const reactions = converter.reactions(misskeyReactions)
|
||||
expect(reactions).toEqual([
|
||||
{
|
||||
count: 3,
|
||||
me: false,
|
||||
name: '❤'
|
||||
},
|
||||
{
|
||||
count: 1,
|
||||
me: false,
|
||||
name: '☺'
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('status', () => {
|
||||
describe('plain content', () => {
|
||||
it('should be exported plain content and html content', () => {
|
||||
const plainContent = 'hoge\nfuga\nfuga'
|
||||
const content = 'hoge<br>fuga<br>fuga'
|
||||
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: {},
|
||||
emojis: [],
|
||||
fileIds: [],
|
||||
files: [],
|
||||
replyId: null,
|
||||
renoteId: null
|
||||
}
|
||||
const megalodonStatus = converter.note(note, user.host || 'misskey.io')
|
||||
expect(megalodonStatus.plain_content).toEqual(plainContent)
|
||||
expect(megalodonStatus.content).toEqual(content)
|
||||
})
|
||||
it('html tags should be escaped', () => {
|
||||
const plainContent = '<p>hoge\nfuga\nfuga<p>'
|
||||
const content = '<p>hoge<br>fuga<br>fuga<p>'
|
||||
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: {},
|
||||
emojis: [],
|
||||
fileIds: [],
|
||||
files: [],
|
||||
replyId: null,
|
||||
renoteId: null
|
||||
}
|
||||
const megalodonStatus = converter.note(note, user.host || 'misskey.io')
|
||||
expect(megalodonStatus.plain_content).toEqual(plainContent)
|
||||
expect(megalodonStatus.content).toEqual(content)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,152 +0,0 @@
|
|||
import { Parser } from '@/parser'
|
||||
import Entity from '@/entity'
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: [],
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
reactions: [],
|
||||
bookmarked: false,
|
||||
quote: null
|
||||
}
|
||||
|
||||
const notification: Entity.Notification = {
|
||||
id: '1',
|
||||
account: account,
|
||||
status: status,
|
||||
type: 'favourite',
|
||||
created_at: '2019-04-01T17:01:32'
|
||||
}
|
||||
|
||||
const conversation: Entity.Conversation = {
|
||||
id: '1',
|
||||
accounts: [account],
|
||||
last_status: status,
|
||||
unread: true
|
||||
}
|
||||
|
||||
describe('Parser', () => {
|
||||
let parser: Parser
|
||||
|
||||
beforeEach(() => {
|
||||
parser = new Parser()
|
||||
})
|
||||
|
||||
describe('parse', () => {
|
||||
describe('message is heartbeat', () => {
|
||||
const message: string = ':thump\n'
|
||||
it('should be called', () => {
|
||||
const spy = jest.fn()
|
||||
parser.on('heartbeat', spy)
|
||||
parser.parse(message)
|
||||
expect(spy).toHaveBeenLastCalledWith({})
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is not json', () => {
|
||||
describe('event is delete', () => {
|
||||
const message = `event: delete\ndata: 12asdf34\n\n`
|
||||
it('should be called', () => {
|
||||
const spy = jest.fn()
|
||||
parser.once('delete', spy)
|
||||
parser.parse(message)
|
||||
expect(spy).toHaveBeenCalledWith('12asdf34')
|
||||
})
|
||||
})
|
||||
|
||||
describe('event is not delete', () => {
|
||||
const message = `event: event\ndata: 12asdf34\n\n`
|
||||
it('should be error', () => {
|
||||
const error = jest.fn()
|
||||
const deleted = jest.fn()
|
||||
parser.once('error', error)
|
||||
parser.once('delete', deleted)
|
||||
parser.parse(message)
|
||||
expect(error).toHaveBeenCalled()
|
||||
expect(deleted).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is json', () => {
|
||||
describe('event is update', () => {
|
||||
const message = `event: update\ndata: ${JSON.stringify(status)}\n\n`
|
||||
it('should be called', () => {
|
||||
const spy = jest.fn()
|
||||
parser.once('update', spy)
|
||||
parser.parse(message)
|
||||
expect(spy).toHaveBeenCalledWith(status)
|
||||
})
|
||||
})
|
||||
|
||||
describe('event is notification', () => {
|
||||
const message = `event: notification\ndata: ${JSON.stringify(notification)}\n\n`
|
||||
it('should be called', () => {
|
||||
const spy = jest.fn()
|
||||
parser.once('notification', spy)
|
||||
parser.parse(message)
|
||||
expect(spy).toHaveBeenCalledWith(notification)
|
||||
})
|
||||
})
|
||||
|
||||
describe('event is conversation', () => {
|
||||
const message = `event: conversation\ndata: ${JSON.stringify(conversation)}\n\n`
|
||||
it('should be called', () => {
|
||||
const spy = jest.fn()
|
||||
parser.once('conversation', spy)
|
||||
parser.parse(message)
|
||||
expect(spy).toHaveBeenCalledWith(conversation)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "0.1.65",
|
||||
"@swc/core": "1.3.105",
|
||||
"@swc/core": "1.3.107",
|
||||
"@swc/core-android-arm64": "1.3.11",
|
||||
"firefish-js": "workspace:*",
|
||||
"idb-keyval": "6.2.1",
|
||||
|
|
2478
pnpm-lock.yaml
2478
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue