mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	fix: megalodon reblogged and favourited user info, add createdAt to note
This commit is contained in:
		
							parent
							
								
									74213ba2b9
								
							
						
					
					
						commit
						a7778e6425
					
				
					 5 changed files with 11 additions and 9 deletions
				
			
		| 
						 | 
					@ -71,7 +71,7 @@ export class ApiStatusMastodon {
 | 
				
			||||||
			const accessTokens = _request.headers.authorization;
 | 
								const accessTokens = _request.headers.authorization;
 | 
				
			||||||
			const client = getClient(BASE_URL, accessTokens);
 | 
								const client = getClient(BASE_URL, accessTokens);
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				const data = await client.getStatusRebloggedBy(convertId(_request.params.id, IdType.SharkeyId));
 | 
									const data = await client.getStatusRebloggedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
 | 
				
			||||||
				reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
 | 
									reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
 | 
				
			||||||
			} catch (e: any) {
 | 
								} catch (e: any) {
 | 
				
			||||||
				console.error(e);
 | 
									console.error(e);
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ export class ApiStatusMastodon {
 | 
				
			||||||
			const accessTokens = _request.headers.authorization;
 | 
								const accessTokens = _request.headers.authorization;
 | 
				
			||||||
			const client = getClient(BASE_URL, accessTokens);
 | 
								const client = getClient(BASE_URL, accessTokens);
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				const data = await client.getStatusFavouritedBy(convertId(_request.params.id, IdType.SharkeyId));
 | 
									const data = await client.getStatusFavouritedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
 | 
				
			||||||
				reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
 | 
									reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
 | 
				
			||||||
			} catch (e: any) {
 | 
								} catch (e: any) {
 | 
				
			||||||
				console.error(e);
 | 
									console.error(e);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ namespace Entity {
 | 
				
			||||||
    content: string
 | 
					    content: string
 | 
				
			||||||
    plain_content: string | null
 | 
					    plain_content: string | null
 | 
				
			||||||
    created_at: string
 | 
					    created_at: string
 | 
				
			||||||
 | 
					    createdAt?: string
 | 
				
			||||||
    emojis: Emoji[]
 | 
					    emojis: Emoji[]
 | 
				
			||||||
    replies_count: number
 | 
					    replies_count: number
 | 
				
			||||||
    reblogs_count: number
 | 
					    reblogs_count: number
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -734,14 +734,14 @@ export interface MegalodonInterface {
 | 
				
			||||||
   * @param id The target status id.
 | 
					   * @param id The target status id.
 | 
				
			||||||
   * @return Array of accounts.
 | 
					   * @return Array of accounts.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>>
 | 
					  getStatusRebloggedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * See who favourited a status
 | 
					   * See who favourited a status
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
   * @param id The target status id.
 | 
					   * @param id The target status id.
 | 
				
			||||||
   * @return Array of accounts.
 | 
					   * @return Array of accounts.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>>
 | 
					  getStatusFavouritedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Favourite a status.
 | 
					   * Favourite a status.
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1177,25 +1177,25 @@ export default class Misskey implements MegalodonInterface {
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * POST /api/notes/renotes
 | 
					   * POST /api/notes/renotes
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public async getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
 | 
					  public async getStatusRebloggedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>> {
 | 
				
			||||||
    return this.client
 | 
					    return this.client
 | 
				
			||||||
      .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/renotes', {
 | 
					      .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/renotes', {
 | 
				
			||||||
        noteId: id
 | 
					        noteId: id
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      .then(res => ({
 | 
					      .then(res => ({
 | 
				
			||||||
        ...res,
 | 
					        ...res,
 | 
				
			||||||
        data: res.data.map(n => MisskeyAPI.Converter.user(n.user))
 | 
					        data: res.data.map(n => MisskeyAPI.Converter.user(n.user, host))
 | 
				
			||||||
      }))
 | 
					      }))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public async getStatusFavouritedBy(_id: string): Promise<Response<Array<Entity.Account>>> {
 | 
					  public async getStatusFavouritedBy(_id: string, host?: string): Promise<Response<Array<Entity.Account>>> {
 | 
				
			||||||
    return this.client.post<Array<MisskeyAPI.Entity.Reaction>>("/api/notes/reactions", {
 | 
					    return this.client.post<Array<MisskeyAPI.Entity.Reaction>>("/api/notes/reactions", {
 | 
				
			||||||
      noteId: _id,
 | 
					      noteId: _id,
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    .then(async (res) => ({
 | 
					    .then(async (res) => ({
 | 
				
			||||||
      ...res,
 | 
					      ...res,
 | 
				
			||||||
      data: (
 | 
					      data: (
 | 
				
			||||||
        await Promise.all(res.data.map((n) => this.getAccount(n.user.id)))
 | 
					        await Promise.all(res.data.map((n) => this.getAccount(n.user.id, host)))
 | 
				
			||||||
      ).map((p) => p.data),
 | 
					      ).map((p) => p.data),
 | 
				
			||||||
    }));
 | 
					    }));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -256,7 +256,7 @@ namespace MisskeyAPI {
 | 
				
			||||||
        account: user(n.user, n.user.host ? n.user.host : host ? host : null),
 | 
					        account: user(n.user, n.user.host ? n.user.host : 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, n.user.host ? n.user.host : host ? host : null) : null,
 | 
				
			||||||
        content: n.text
 | 
					        content: n.text
 | 
				
			||||||
          ? n.text
 | 
					          ? n.text
 | 
				
			||||||
              .replace(/&/g, '&')
 | 
					              .replace(/&/g, '&')
 | 
				
			||||||
| 
						 | 
					@ -269,6 +269,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,
 | 
				
			||||||
 | 
					        createdAt: n.createdAt,
 | 
				
			||||||
        emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
 | 
					        emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
 | 
				
			||||||
        replies_count: n.repliesCount,
 | 
					        replies_count: n.repliesCount,
 | 
				
			||||||
        reblogs_count: n.renoteCount,
 | 
					        reblogs_count: n.renoteCount,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue