Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getRelationship interface to get one account #267

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/typescript/src/mastodon/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions example/typescript/src/mastodon/relationship.ts
Original file line number Diff line number Diff line change
@@ -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)
})
8 changes: 4 additions & 4 deletions src/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/megalodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
6 changes: 3 additions & 3 deletions src/misskey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down