2018-01-19 04:25:34 +00:00
|
|
|
import { get, paramsString } from '../ajax'
|
2018-01-19 05:52:58 +00:00
|
|
|
import { basename } from './utils'
|
2018-01-19 04:25:34 +00:00
|
|
|
|
2018-01-19 07:37:43 +00:00
|
|
|
export function getTimeline(instanceName, accessToken, timeline, maxId, since) {
|
|
|
|
let timelineUrlName = timeline === 'local' || timeline === 'federated' ? 'public' : timeline
|
|
|
|
let url = `${basename(instanceName)}/api/v1/timelines/${timelineUrlName}`
|
2018-01-19 04:25:34 +00:00
|
|
|
|
|
|
|
let params = {}
|
|
|
|
if (since) {
|
|
|
|
params.since = since
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxId) {
|
|
|
|
params.max_id = maxId
|
|
|
|
}
|
|
|
|
|
2018-01-19 07:37:43 +00:00
|
|
|
if (timeline === 'local') {
|
|
|
|
params.local = true
|
|
|
|
}
|
|
|
|
|
2018-01-19 04:25:34 +00:00
|
|
|
url += '?' + paramsString(params)
|
|
|
|
|
|
|
|
return get(url, {
|
|
|
|
'Authorization': `Bearer ${accessToken}`
|
|
|
|
})
|
|
|
|
}
|