pinafore/routes/_utils/mastodon/timelines.js
2018-01-18 23:37:43 -08:00

26 lines
610 B
JavaScript

import { get, paramsString } from '../ajax'
import { basename } from './utils'
export function getTimeline(instanceName, accessToken, timeline, maxId, since) {
let timelineUrlName = timeline === 'local' || timeline === 'federated' ? 'public' : timeline
let url = `${basename(instanceName)}/api/v1/timelines/${timelineUrlName}`
let params = {}
if (since) {
params.since = since
}
if (maxId) {
params.max_id = maxId
}
if (timeline === 'local') {
params.local = true
}
url += '?' + paramsString(params)
return get(url, {
'Authorization': `Bearer ${accessToken}`
})
}