mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-29 09:03:01 +00:00
add: converter export from megalodon
This commit is contained in:
parent
f151ab2258
commit
72ff1ffc9d
3 changed files with 21 additions and 7 deletions
3
packages/megalodon/src/converter.ts
Normal file
3
packages/megalodon/src/converter.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import MisskeyAPI from "./misskey/api_client";
|
||||||
|
|
||||||
|
export default MisskeyAPI.Converter;
|
|
@ -10,6 +10,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,
|
||||||
|
@ -25,7 +26,8 @@ export {
|
||||||
Mastodon,
|
Mastodon,
|
||||||
Pleroma,
|
Pleroma,
|
||||||
Misskey,
|
Misskey,
|
||||||
Entity
|
Entity,
|
||||||
|
Converter
|
||||||
}
|
}
|
||||||
|
|
||||||
export default generator
|
export default generator
|
||||||
|
|
|
@ -68,11 +68,15 @@ namespace MisskeyAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const user = (u: Entity.User): MegalodonEntity.Account => {
|
export const user = (u: Entity.User, host: string | null = null): MegalodonEntity.Account => {
|
||||||
|
host ? host = host.replace("https://", "") : null;
|
||||||
let acct = u.username
|
let acct = u.username
|
||||||
if (u.host) {
|
if (u.host) {
|
||||||
acct = `${u.username}@${u.host}`
|
acct = `${u.username}@${u.host}`
|
||||||
}
|
}
|
||||||
|
if (host) {
|
||||||
|
acct = `${u.username}@${host}`
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
id: u.id,
|
id: u.id,
|
||||||
username: u.username,
|
username: u.username,
|
||||||
|
@ -100,11 +104,15 @@ namespace MisskeyAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userDetail = (u: Entity.UserDetail): MegalodonEntity.Account => {
|
export const userDetail = (u: Entity.UserDetail, host: string | null = null): MegalodonEntity.Account => {
|
||||||
|
host ? host = host.replace("https://", "") : null;
|
||||||
let acct = u.username
|
let acct = u.username
|
||||||
if (u.host) {
|
if (u.host) {
|
||||||
acct = `${u.username}@${u.host}`
|
acct = `${u.username}@${u.host}`
|
||||||
}
|
}
|
||||||
|
if (host) {
|
||||||
|
acct = `${u.username}@${host}`
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
id: u.id,
|
id: u.id,
|
||||||
username: u.username,
|
username: u.username,
|
||||||
|
@ -239,12 +247,13 @@ namespace MisskeyAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const note = (n: Entity.Note): MegalodonEntity.Status => {
|
export const note = (n: Entity.Note, host: string | null = null): MegalodonEntity.Status => {
|
||||||
|
host ? host = host.replace("https://", "") : null;
|
||||||
return {
|
return {
|
||||||
id: n.id,
|
id: n.id,
|
||||||
uri: n.uri ? n.uri : '',
|
uri: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
|
||||||
url: n.uri ? n.uri : '',
|
url: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
|
||||||
account: user(n.user),
|
account: user(n.user, host ? host : null),
|
||||||
in_reply_to_id: n.replyId,
|
in_reply_to_id: n.replyId,
|
||||||
in_reply_to_account_id: null,
|
in_reply_to_account_id: null,
|
||||||
reblog: n.renote ? note(n.renote) : null,
|
reblog: n.renote ? note(n.renote) : null,
|
||||||
|
|
Loading…
Reference in a new issue