refs #668 Support notify options in follow for Mastodon

This commit is contained in:
AkiraFukushima 2021-03-02 13:23:36 +09:00
parent db7061fa51
commit 33cf947ed6
4 changed files with 32 additions and 12 deletions

View file

@ -446,12 +446,19 @@ export default class Mastodon implements MegalodonInterface {
})
}
public async followAccount(id: string, reblog?: boolean): Promise<Response<Entity.Relationship>> {
public async followAccount(id: string, options?: { reblog?: boolean; notify?: boolean }): Promise<Response<Entity.Relationship>> {
let params = {}
if (reblog !== undefined) {
params = Object.assign(params, {
reblog: reblog
})
if (options) {
if (options.reblog !== undefined) {
params = Object.assign(params, {
reblog: options.reblog
})
}
if (options.notify !== undefined) {
params = Object.assign(params, {
notify: options.notify
})
}
}
return this.client.post<MastodonAPI.Entity.Relationship>(`/api/v1/accounts/${id}/follow`, params).then(res => {
return Object.assign(res, {

View file

@ -272,7 +272,13 @@ export interface MegalodonInterface {
* @param reblog Receive this account's reblogs in home timeline.
* @return Relationship
*/
followAccount(id: string, reblog?: boolean): Promise<Response<Entity.Relationship>>
followAccount(
id: string,
options?: {
reblog?: boolean
notify?: boolean
}
): Promise<Response<Entity.Relationship>>
/**
* POST /api/v1/accounts/:id/unfollow
*

View file

@ -454,7 +454,7 @@ export default class Misskey implements MegalodonInterface {
/**
* POST /api/following/create
*/
public async followAccount(id: string, _reblog?: boolean): Promise<Response<Entity.Relationship>> {
public async followAccount(id: string, _options?: { reblog?: boolean; notify?: boolean }): Promise<Response<Entity.Relationship>> {
await this.client.post<{}>('/api/following/create', {
userId: id
})

View file

@ -467,12 +467,19 @@ export default class Pleroma implements MegalodonInterface {
})
}
public async followAccount(id: string, reblog?: boolean): Promise<Response<Entity.Relationship>> {
public async followAccount(id: string, options?: { reblog?: boolean; notify?: boolean }): Promise<Response<Entity.Relationship>> {
let params = {}
if (reblog !== undefined) {
params = Object.assign(params, {
reblog: reblog
})
if (options) {
if (options.reblog !== undefined) {
params = Object.assign(params, {
reblog: options.reblog
})
}
if (options.notify !== undefined) {
params = Object.assign(params, {
notify: options.notify
})
}
}
return this.client.post<PleromaAPI.Entity.Relationship>(`/api/v1/accounts/${id}/follow`, params).then(res => {
return Object.assign(res, {