Fix getRelationship interface to get one account

This commit is contained in:
AkiraFukushima 2020-03-18 22:40:38 +09:00
parent 14e3e406fa
commit d5157cc965
5 changed files with 27 additions and 10 deletions

View file

@ -7,7 +7,7 @@ const rl: readline.ReadLine = readline.createInterface({
})
const SCOPES: Array<string> = ['read', 'write', 'follow']
const BASE_URL: string = 'https://mstdn.maud.io'
const BASE_URL: string = 'https://mastodon.social'
let clientId: string
let clientSecret: string

View file

@ -0,0 +1,17 @@
import generator from 'megalodon'
declare var process: {
env: {
MASTODON_ACCESS_TOKEN: string
}
}
const BASE_URL: string = 'https://mastodon.social'
const access_token: string = process.env.MASTODON_ACCESS_TOKEN
const client = generator('mastodon', BASE_URL, access_token)
client.getRelationship('1').then(res => {
console.log(res.data)
})

View file

@ -502,14 +502,14 @@ export default class Mastodon implements MegalodonInterface {
})
}
public async getRelationship(ids: Array<string>): Promise<Response<Entity.Relationship>> {
public async getRelationship(id: string): Promise<Response<Entity.Relationship>> {
return this.client
.get<MastodonAPI.Entity.Relationship>('/api/v1/accounts/relationships', {
id: ids
.get<Array<MastodonAPI.Entity.Relationship>>('/api/v1/accounts/relationships', {
id: [id]
})
.then(res => {
return Object.assign(res, {
data: MastodonAPI.Converter.relationship(res.data)
data: MastodonAPI.Converter.relationship(res.data[0])
})
})
}

View file

@ -310,10 +310,10 @@ export interface MegalodonInterface {
/**
* GET /api/v1/accounts/relationships
*
* @param ids Array of account IDs.
* @param id The account ID.
* @return Relationship
*/
getRelationship(ids: Array<string>): Promise<Response<Entity.Relationship>>
getRelationship(id: string): Promise<Response<Entity.Relationship>>
/**
* GET /api/v1/accounts/search
*

View file

@ -552,12 +552,12 @@ export default class Misskey implements MegalodonInterface {
/**
* POST /api/users/relation
*
* @param ids Array of the accountID, for example `['1sdfag']`. Only the first element is used.
* @param id The accountID, for example `'1sdfag'`
*/
public async getRelationship(ids: Array<string>): Promise<Response<Entity.Relationship>> {
public async getRelationship(id: string): Promise<Response<Entity.Relationship>> {
return this.client
.post<MisskeyAPI.Entity.Relation>('/api/users/relation', {
userId: ids[0]
userId: id
})
.then(res => {
return Object.assign(res, {