Fix getRelationship interface to get one account
This commit is contained in:
parent
14e3e406fa
commit
d5157cc965
|
@ -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
|
||||
|
|
17
example/typescript/src/mastodon/relationship.ts
Normal file
17
example/typescript/src/mastodon/relationship.ts
Normal 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)
|
||||
})
|
|
@ -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])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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, {
|
||||
|
|
Loading…
Reference in a new issue