2018-02-25 05:27:32 +00:00
|
|
|
import { favoriteStatus } from '../routes/_api/favorite'
|
|
|
|
import fetch from 'node-fetch'
|
2018-03-10 18:54:16 +00:00
|
|
|
import FileApi from 'file-api'
|
2018-03-06 04:29:49 +00:00
|
|
|
import { users } from './users'
|
2018-03-10 18:54:16 +00:00
|
|
|
import { postStatus } from '../routes/_api/statuses'
|
2018-03-11 00:21:10 +00:00
|
|
|
import { deleteStatus } from '../routes/_api/delete'
|
2018-03-15 05:14:06 +00:00
|
|
|
import { authorizeFollowRequest, getFollowRequests } from '../routes/_actions/followRequests'
|
2018-04-28 21:19:39 +00:00
|
|
|
import { followAccount, unfollowAccount } from '../routes/_api/follow'
|
2018-08-19 22:23:40 +00:00
|
|
|
import { updateCredentials } from '../routes/_api/updateCredentials'
|
2018-08-28 13:45:15 +00:00
|
|
|
import { reblogStatus } from '../routes/_api/reblog'
|
2018-12-01 08:10:30 +00:00
|
|
|
import { submitMedia } from './submitMedia'
|
2018-03-10 18:54:16 +00:00
|
|
|
|
2018-03-06 07:56:48 +00:00
|
|
|
global.fetch = fetch
|
2018-03-10 18:54:16 +00:00
|
|
|
global.File = FileApi.File
|
|
|
|
global.FormData = FileApi.FormData
|
2018-02-25 05:27:32 +00:00
|
|
|
|
2018-03-11 00:21:10 +00:00
|
|
|
const instanceName = 'localhost:3000'
|
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function favoriteStatusAs (username, statusId) {
|
|
|
|
return favoriteStatus(instanceName, users[username].accessToken, statusId)
|
2018-02-25 05:27:32 +00:00
|
|
|
}
|
2018-03-10 18:54:16 +00:00
|
|
|
|
2018-08-28 13:45:15 +00:00
|
|
|
export async function reblogStatusAs (username, statusId) {
|
|
|
|
return reblogStatus(instanceName, users[username].accessToken, statusId)
|
|
|
|
}
|
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function postAs (username, text) {
|
|
|
|
return postStatus(instanceName, users[username].accessToken, text,
|
2018-03-10 18:54:16 +00:00
|
|
|
null, null, false, null, 'public')
|
|
|
|
}
|
2018-03-11 00:21:10 +00:00
|
|
|
|
2018-12-01 08:10:30 +00:00
|
|
|
export async function postEmptyStatusWithMediaAs (username, filename, alt) {
|
|
|
|
let mediaResponse = await submitMedia(users[username].accessToken, filename, alt)
|
|
|
|
return postStatus(instanceName, users[username].accessToken, '',
|
|
|
|
null, [mediaResponse.id], false, null, 'public')
|
|
|
|
}
|
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function postReplyAs (username, text, inReplyTo) {
|
|
|
|
return postStatus(instanceName, users[username].accessToken, text,
|
2018-03-11 04:24:07 +00:00
|
|
|
inReplyTo, null, false, null, 'public')
|
|
|
|
}
|
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function deleteAs (username, statusId) {
|
|
|
|
return deleteStatus(instanceName, users[username].accessToken, statusId)
|
2018-03-11 00:21:10 +00:00
|
|
|
}
|
2018-03-15 05:14:06 +00:00
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function getFollowRequestsAs (username) {
|
|
|
|
return getFollowRequests(instanceName, users[username].accessToken)
|
2018-03-15 05:14:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-16 17:06:02 +00:00
|
|
|
export async function authorizeFollowRequestAs (username, id) {
|
|
|
|
return authorizeFollowRequest(instanceName, users[username].accessToken, id)
|
2018-03-15 05:14:06 +00:00
|
|
|
}
|
2018-04-28 21:19:39 +00:00
|
|
|
|
|
|
|
export async function followAs (username, userToFollow) {
|
|
|
|
return followAccount(instanceName, users[username].accessToken, users[userToFollow].id)
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function unfollowAs (username, userToFollow) {
|
|
|
|
return unfollowAccount(instanceName, users[username].accessToken, users[userToFollow].id)
|
|
|
|
}
|
2018-08-19 22:23:40 +00:00
|
|
|
|
|
|
|
export async function updateUserDisplayNameAs (username, displayName) {
|
2018-08-30 04:42:57 +00:00
|
|
|
return updateCredentials(instanceName, users[username].accessToken, { display_name: displayName })
|
2018-08-19 22:23:40 +00:00
|
|
|
}
|