5.1.9
This commit is contained in:
parent
d4ad0d2e38
commit
0aa115f8f8
|
@ -8,6 +8,7 @@
|
||||||
"author": "h3poteto",
|
"author": "h3poteto",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@cutls/megalodon": "5.1.6",
|
||||||
"megalodon": "*",
|
"megalodon": "*",
|
||||||
"typescript": "4.9.4"
|
"typescript": "4.9.4"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import generator, { MegalodonInterface, Entity, Response } from 'megalodon'
|
import generator, { MegalodonInterface, Entity, Response, Converter } from '@cutls/megalodon'
|
||||||
|
|
||||||
declare var process: {
|
declare var process: {
|
||||||
env: {
|
env: {
|
||||||
|
@ -6,15 +6,15 @@ declare var process: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BASE_URL: string = 'https://misskey.io'
|
const BASE_URL: string = 'https://chkukfsatpl3.cutls.dev'
|
||||||
|
|
||||||
const access_token: string = process.env.MISSKEY_ACCESS_TOKEN
|
const access_token: string = process.env.MISSKEY_ACCESS_TOKEN || '8zrWrxUIBNQ0kWUw'
|
||||||
|
|
||||||
const client: MegalodonInterface = generator('misskey', BASE_URL, access_token)
|
const client: MegalodonInterface = generator('misskey', BASE_URL, access_token)
|
||||||
|
|
||||||
client
|
client
|
||||||
.getHomeTimeline()
|
.getLocalTimeline()
|
||||||
.then((resp: Response<Array<Entity.Status>>) => {
|
.then((resp: Response<Array<Entity.Status>>) => {
|
||||||
console.log(resp.data)
|
console.log(resp.data.map((t) => t.emojis))
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
|
|
3
megalodon/src/converter.ts
Normal file
3
megalodon/src/converter.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import MisskeyAPI from "./misskey/api_client";
|
||||||
|
|
||||||
|
export default MisskeyAPI.Converter
|
|
@ -9,6 +9,7 @@ import Misskey from './misskey'
|
||||||
import Entity from './entity'
|
import Entity from './entity'
|
||||||
import NotificationType from './notification'
|
import NotificationType from './notification'
|
||||||
import FilterContext from './filter_context'
|
import FilterContext from './filter_context'
|
||||||
|
import Converter from './converter'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Response,
|
Response,
|
||||||
|
@ -24,7 +25,8 @@ export {
|
||||||
Mastodon,
|
Mastodon,
|
||||||
Pleroma,
|
Pleroma,
|
||||||
Misskey,
|
Misskey,
|
||||||
Entity
|
Entity,
|
||||||
|
Converter
|
||||||
}
|
}
|
||||||
|
|
||||||
export default generator
|
export default generator
|
||||||
|
|
|
@ -57,6 +57,7 @@ export default class Misskey implements MegalodonInterface {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/app/create
|
* POST /api/app/create
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,13 +52,13 @@ namespace MisskeyAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const emojiConverter = (e: MisskeyEntity.EmojiKeyValue | MisskeyEntity.Emoji[]) => {
|
export const emojiConverter = (e: MisskeyEntity.EmojiKeyValue | MisskeyEntity.Emoji[]) => {
|
||||||
|
if (!e) return []
|
||||||
if (isEmojiArr(e)) return e
|
if (isEmojiArr(e)) return e
|
||||||
const emojiKeys = Object.keys(e)
|
const emojiArr: MisskeyEntity.Emoji[] = Object.entries(e).map(([key, value], i) => {
|
||||||
const emojiArr: MisskeyEntity.Emoji[] = emojiKeys.map((emoji, i) => {
|
|
||||||
return {
|
return {
|
||||||
name: emojiKeys[i],
|
name: key,
|
||||||
host: null,
|
host: null,
|
||||||
url: emoji,
|
url: value,
|
||||||
aliases: []
|
aliases: []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -67,8 +67,10 @@ namespace MisskeyAPI {
|
||||||
|
|
||||||
export const user = (u: Entity.User): MegalodonEntity.Account => {
|
export const user = (u: Entity.User): MegalodonEntity.Account => {
|
||||||
let acct = u.username
|
let acct = u.username
|
||||||
|
let acctUrl = `https://${u.host || 'example.com'}/@${u.username}`
|
||||||
if (u.host) {
|
if (u.host) {
|
||||||
acct = `${u.username}@${u.host}`
|
acct = `${u.username}@${u.host}`
|
||||||
|
acctUrl = `https://${u.host}/@${u.username}`
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: u.id,
|
id: u.id,
|
||||||
|
@ -76,27 +78,29 @@ namespace MisskeyAPI {
|
||||||
acct: acct,
|
acct: acct,
|
||||||
display_name: u.name,
|
display_name: u.name,
|
||||||
locked: false,
|
locked: false,
|
||||||
created_at: '',
|
created_at: new Date().toISOString(),
|
||||||
followers_count: 0,
|
followers_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
statuses_count: 0,
|
statuses_count: 0,
|
||||||
note: '',
|
note: '',
|
||||||
url: acct,
|
url: acctUrl,
|
||||||
avatar: u.avatarUrl,
|
avatar: u.avatarUrl,
|
||||||
avatar_static: u.avatarColor,
|
avatar_static: u.avatarUrl,
|
||||||
header: '',
|
header: '',
|
||||||
header_static: '',
|
header_static: '',
|
||||||
emojis: emojiConverter(u.emojis).map(e => emoji(e)),
|
emojis: emojiConverter(u.emojis).map(e => emoji(e)),
|
||||||
moved: null,
|
moved: null,
|
||||||
fields: [],
|
fields: [],
|
||||||
bot: null
|
bot: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userDetail = (u: Entity.UserDetail): MegalodonEntity.Account => {
|
export const userDetail = (u: Entity.UserDetail): MegalodonEntity.Account => {
|
||||||
let acct = u.username
|
let acct = u.username
|
||||||
|
let acctUrl = `https://${u.host || 'example.com'}/@${u.username}`
|
||||||
if (u.host) {
|
if (u.host) {
|
||||||
acct = `${u.username}@${u.host}`
|
acct = `${u.username}@${u.host}`
|
||||||
|
acctUrl = `https://${u.host}/@${u.username}`
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: u.id,
|
id: u.id,
|
||||||
|
@ -109,15 +113,15 @@ namespace MisskeyAPI {
|
||||||
following_count: u.followingCount,
|
following_count: u.followingCount,
|
||||||
statuses_count: u.notesCount,
|
statuses_count: u.notesCount,
|
||||||
note: u.description,
|
note: u.description,
|
||||||
url: acct,
|
url: acctUrl,
|
||||||
avatar: u.avatarUrl,
|
avatar: u.avatarUrl,
|
||||||
avatar_static: u.avatarColor,
|
avatar_static: u.avatarUrl,
|
||||||
header: u.bannerUrl,
|
header: u.bannerUrl,
|
||||||
header_static: u.bannerColor,
|
header_static: u.bannerUrl,
|
||||||
emojis: emojiConverter(u.emojis).map(e => emoji(e)),
|
emojis: emojiConverter(u.emojis).map(e => emoji(e)),
|
||||||
moved: null,
|
moved: null,
|
||||||
fields: [],
|
fields: [],
|
||||||
bot: u.isBot
|
bot: u.isBot || false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +252,7 @@ namespace MisskeyAPI {
|
||||||
: '',
|
: '',
|
||||||
plain_content: n.text ? n.text : null,
|
plain_content: n.text ? n.text : null,
|
||||||
created_at: n.createdAt,
|
created_at: n.createdAt,
|
||||||
emojis: n.emojis.map(e => emoji(e)),
|
emojis: emojiConverter(n.emojis).map(e => emoji(e)),
|
||||||
replies_count: n.repliesCount,
|
replies_count: n.repliesCount,
|
||||||
reblogs_count: n.renoteCount,
|
reblogs_count: n.renoteCount,
|
||||||
favourites_count: 0,
|
favourites_count: 0,
|
||||||
|
@ -366,11 +370,35 @@ namespace MisskeyAPI {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const modelOfAcct = {
|
||||||
|
id: "1",
|
||||||
|
username: 'none',
|
||||||
|
acct: 'none',
|
||||||
|
display_name: 'none',
|
||||||
|
locked: true,
|
||||||
|
bot: true,
|
||||||
|
discoverable: false,
|
||||||
|
group: false,
|
||||||
|
created_at: '1971-01-01T00:00:00.000Z',
|
||||||
|
note: '',
|
||||||
|
url: 'https://example.com',
|
||||||
|
avatar: '/missing',
|
||||||
|
avatar_static: '/missing',
|
||||||
|
header: '/missing',
|
||||||
|
header_static: '/missing',
|
||||||
|
followers_count: -1,
|
||||||
|
following_count: 0,
|
||||||
|
statuses_count: 0,
|
||||||
|
last_status_at: '1971-01-01T00:00:00.000Z',
|
||||||
|
noindex: true,
|
||||||
|
emojis: [],
|
||||||
|
fields: []
|
||||||
|
}
|
||||||
|
|
||||||
export const notification = (n: Entity.Notification): MegalodonEntity.Notification => {
|
export const notification = (n: Entity.Notification): MegalodonEntity.Notification => {
|
||||||
let notification = {
|
let notification = {
|
||||||
id: n.id,
|
id: n.id,
|
||||||
account: user(n.user),
|
account: n.user ? user(n.user) : modelOfAcct,
|
||||||
created_at: n.createdAt,
|
created_at: n.createdAt,
|
||||||
type: decodeNotificationType(n.type)
|
type: decodeNotificationType(n.type)
|
||||||
}
|
}
|
||||||
|
|
19
yarn.lock
19
yarn.lock
|
@ -3927,6 +3927,25 @@ md5.js@^1.3.4:
|
||||||
inherits "^2.0.1"
|
inherits "^2.0.1"
|
||||||
safe-buffer "^5.1.2"
|
safe-buffer "^5.1.2"
|
||||||
|
|
||||||
|
megalodon@*:
|
||||||
|
version "5.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/megalodon/-/megalodon-5.1.1.tgz#291050f335da302689b46ad47155971a84c6ca58"
|
||||||
|
integrity sha512-zsYzzmogmk9lnXzGk3kKv58LUmZVFMebiya/1CZqZYnBVxq18Ep8l1AU41o+INANMqYxG+hAQvJhE+Z5dcUabQ==
|
||||||
|
dependencies:
|
||||||
|
"@types/oauth" "^0.9.0"
|
||||||
|
"@types/ws" "^8.5.4"
|
||||||
|
axios "1.2.2"
|
||||||
|
dayjs "^1.11.7"
|
||||||
|
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"
|
||||||
|
typescript "4.9.4"
|
||||||
|
uuid "^9.0.0"
|
||||||
|
ws "8.12.0"
|
||||||
|
|
||||||
merge-stream@^2.0.0:
|
merge-stream@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
|
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
|
||||||
|
|
Loading…
Reference in a new issue