Merge pull request #236 from h3poteto/local-timeline

Implement getLocalTimeline method
This commit is contained in:
AkiraFukushima 2020-03-04 00:01:25 +09:00 committed by GitHub
commit 4d9778e3c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 6 deletions

View file

@ -1266,19 +1266,57 @@ export default class Mastodon implements MegalodonInterface {
// timelines
// ======================================
public async getPublicTimeline(
local?: boolean | null,
only_media?: boolean | null,
limit?: number | null,
max_id?: string | null,
since_id?: string | null,
min_id?: string | null
): Promise<Response<Array<Entity.Status>>> {
let params = {}
if (local !== null) {
let params = {
local: false
}
if (only_media !== null) {
params = Object.assign(params, {
local: local
only_media: only_media
})
}
if (max_id) {
params = Object.assign(params, {
max_id: max_id
})
}
if (since_id) {
params = Object.assign(params, {
since_id: since_id
})
}
if (min_id) {
params = Object.assign(params, {
min_id: min_id
})
}
if (limit) {
params = Object.assign(params, {
limit: limit
})
}
return this.client.get<Array<MastodonAPI.Entity.Status>>('/api/v1/timelines/public', params).then(res => {
return Object.assign(res, {
data: res.data.map(s => MastodonAPI.Converter.status(s))
})
})
}
public async getLocalTimeline(
only_media?: boolean | null,
limit?: number | null,
max_id?: string | null,
since_id?: string | null,
min_id?: string | null
): Promise<Response<Array<Entity.Status>>> {
let params = {
local: true
}
if (only_media !== null) {
params = Object.assign(params, {
only_media: only_media

View file

@ -758,7 +758,6 @@ export interface MegalodonInterface {
/**
* GET /api/v1/timelines/public
*
* @param local Show only local statuses? Defaults to false.
* @param only_media Show only statuses with media attached? Defaults to false.
* @param limit Max number of results to return. Defaults to 20.
* @param max_id Return results older than ID.
@ -767,7 +766,23 @@ export interface MegalodonInterface {
* @return Array of statuses.
*/
getPublicTimeline(
local?: boolean | null,
only_media?: boolean | null,
limit?: number | null,
max_id?: string | null,
since_id?: string | null,
min_id?: string | null
): Promise<Response<Array<Entity.Status>>>
/**
* GET /api/v1/timelines/public
*
* @param only_media Show only statuses with media attached? Defaults to false.
* @param limit Max number of results to return. Defaults to 20.
* @param max_id Return results older than ID.
* @param since_id Return results newer than ID.
* @param min_id Return results immediately newer than ID.
* @return Array of statuses.
*/
getLocalTimeline(
only_media?: boolean | null,
limit?: number | null,
max_id?: string | null,