Skip to content

Commit

Permalink
Merge pull request #2174 from h3poteto/feat/lookup
Browse files Browse the repository at this point in the history
Implement accounts lookup method
  • Loading branch information
h3poteto authored May 2, 2024
2 parents 1a1e8dc + bf76f7b commit ec74156
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions megalodon/src/firefish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,13 @@ export default class Firefish implements MegalodonInterface {
})
}

public async lookupAccount(_acct: string): Promise<Response<Entity.Account>> {
return new Promise((_, reject) => {
const err = new NotImplementedError('Firefish does not support this method')
reject(err)
})
}

// ======================================
// accounts/bookmarks
// ======================================
Expand Down
7 changes: 7 additions & 0 deletions megalodon/src/friendica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,13 @@ export default class Friendica implements MegalodonInterface {
})
}

public async lookupAccount(_acct: string): Promise<Response<Entity.Account>> {
return new Promise((_, reject) => {
const err = new NotImplementedError('Friendica does not support this method')
reject(err)
})
}

// ======================================
// accounts/bookmarks
// ======================================
Expand Down
14 changes: 14 additions & 0 deletions megalodon/src/gotosocial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,20 @@ export default class Gotosocial implements MegalodonInterface {
})
}

/**
* GET /api/v1/accounts/lookup
*
* @param acct The username or Webfinger address to lookup.
* @return Account.
*/
public async lookupAccount(acct: string): Promise<Response<Entity.Account>> {
return this.client.get<GotosocialAPI.Entity.Account>(`/api/v1/accounts/lookup?acct=${acct}`).then(res => {
return Object.assign(res, {
data: GotosocialAPI.Converter.account(res.data)
})
})
}

// ======================================
// accounts/bookmarks
// ======================================
Expand Down
14 changes: 14 additions & 0 deletions megalodon/src/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,20 @@ export default class Mastodon implements MegalodonInterface {
})
}

/**
* GET /api/v1/accounts/lookup
*
* @param acct The username or Webfinger address to lookup.
* @return Account.
*/
public async lookupAccount(acct: string): Promise<Response<Entity.Account>> {
return this.client.get<MastodonAPI.Entity.Account>(`/api/v1/accounts/lookup?acct=${acct}`).then(res => {
return Object.assign(res, {
data: MastodonAPI.Converter.account(res.data)
})
})
}

// ======================================
// accounts/bookmarks
// ======================================
Expand Down
8 changes: 8 additions & 0 deletions megalodon/src/megalodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ export interface MegalodonInterface {
since_id?: string
}
): Promise<Response<Array<Entity.Account>>>
/**
* Lookup account ID from Webfinger address.
*
* @param acct Webfinger address.
* @return Account
*/
lookupAccount(acct: string): Promise<Response<Entity.Account>>

// ======================================
// accounts/bookmarks
// ======================================
Expand Down
14 changes: 14 additions & 0 deletions megalodon/src/pleroma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,20 @@ export default class Pleroma implements MegalodonInterface {
})
}

/**
* GET /api/v1/accounts/lookup
*
* @param acct The username or Webfinger address to lookup.
* @return Account.
*/
public async lookupAccount(acct: string): Promise<Response<Entity.Account>> {
return this.client.get<PleromaAPI.Entity.Account>(`/api/v1/accounts/lookup?acct=${acct}`).then(res => {
return Object.assign(res, {
data: PleromaAPI.Converter.account(res.data)
})
})
}

// ======================================
// accounts/bookmarks
// ======================================
Expand Down

0 comments on commit ec74156

Please sign in to comment.