Update branch and fix conflicts.

This commit is contained in:
Shpuld Shpuldson 2017-06-19 11:32:40 +03:00
commit 3785a863cb
47 changed files with 889 additions and 285 deletions

View file

@ -19,9 +19,11 @@ const UNFOLLOWING_URL = '/api/friendships/destroy.json'
const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json'
const REGISTRATION_URL = '/api/account/register.json'
const AVATAR_UPDATE_URL = '/api/qvitter/update_avatar.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json'
// const USER_URL = '/api/users/show.json'
import { each } from 'lodash'
import { each, map } from 'lodash'
const oldfetch = window.fetch
@ -88,6 +90,13 @@ const authHeaders = (user) => {
}
}
const externalProfile = (profileUrl) => {
let url = `${EXTERNAL_PROFILE_URL}?profileurl=${profileUrl}`
return fetch(url, {
method: 'GET'
}).then((data) => data.json())
}
const followUser = ({id, credentials}) => {
let url = `${FOLLOWING_URL}?user_id=${id}`
return fetch(url, {
@ -143,24 +152,34 @@ const setUserMute = ({id, credentials, muted = true}) => {
})
}
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false}) => {
const timelineUrls = {
public: PUBLIC_TIMELINE_URL,
friends: FRIENDS_TIMELINE_URL,
mentions: MENTIONS_URL,
'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL
'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL,
user: QVITTER_USER_TIMELINE_URL
}
let url = timelineUrls[timeline]
let params = []
if (since) {
url += `?since_id=${since}`
params.push(['since_id', since])
}
if (until) {
url += `?max_id=${until}`
params.push(['max_id', until])
}
if (userId) {
params.push(['user_id', userId])
}
const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&')
url += `?${queryString}`
return fetch(url, { headers: authHeaders(credentials) }).then((data) => data.json())
}
@ -253,7 +272,8 @@ const apiService = {
setUserMute,
fetchMutes,
register,
updateAvatar
updateAvatar,
externalProfile
}
export default apiService