mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-03 23:14:13 +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 NotificationType from './notification'
 | 
			
		||||
import FilterContext from './filter_context'
 | 
			
		||||
import Converter from './converter'
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
  Response,
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,8 @@ export {
 | 
			
		|||
  Mastodon,
 | 
			
		||||
  Pleroma,
 | 
			
		||||
  Misskey,
 | 
			
		||||
  Entity
 | 
			
		||||
  Entity,
 | 
			
		||||
  Converter
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
      if (u.host) {
 | 
			
		||||
        acct = `${u.username}@${u.host}`
 | 
			
		||||
      }
 | 
			
		||||
      if (host) {
 | 
			
		||||
        acct = `${u.username}@${host}`
 | 
			
		||||
      }
 | 
			
		||||
      return {
 | 
			
		||||
        id: u.id,
 | 
			
		||||
        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
 | 
			
		||||
      if (u.host) {
 | 
			
		||||
        acct = `${u.username}@${u.host}`
 | 
			
		||||
      }
 | 
			
		||||
      if (host) {
 | 
			
		||||
        acct = `${u.username}@${host}`
 | 
			
		||||
      }
 | 
			
		||||
      return {
 | 
			
		||||
        id: u.id,
 | 
			
		||||
        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 {
 | 
			
		||||
        id: n.id,
 | 
			
		||||
        uri: n.uri ? n.uri : '',
 | 
			
		||||
        url: n.uri ? n.uri : '',
 | 
			
		||||
        account: user(n.user),
 | 
			
		||||
        uri: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
 | 
			
		||||
        url: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
 | 
			
		||||
        account: user(n.user, host ? host : null),
 | 
			
		||||
        in_reply_to_id: n.replyId,
 | 
			
		||||
        in_reply_to_account_id: null,
 | 
			
		||||
        reblog: n.renote ? note(n.renote) : null,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue