pleroma-fe/src/services/backend_interactor_service/backend_interactor_service.js

227 lines
7.8 KiB
JavaScript
Raw Normal View History

import apiService from '../api/api.service.js'
import timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service.js'
2019-04-03 18:04:46 +02:00
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
2019-06-18 22:28:31 +02:00
const backendInteractorService = credentials => {
const fetchStatus = ({ id }) => {
return apiService.fetchStatus({ id, credentials })
}
2019-06-18 22:28:31 +02:00
const fetchConversation = ({ id }) => {
return apiService.fetchConversation({ id, credentials })
}
2019-06-18 22:28:31 +02:00
const fetchFriends = ({ id, maxId, sinceId, limit }) => {
return apiService.fetchFriends({ id, maxId, sinceId, limit, credentials })
2017-08-21 19:25:01 +02:00
}
2019-06-18 22:28:31 +02:00
const exportFriends = ({ id }) => {
return apiService.exportFriends({ id, credentials })
}
2019-06-18 22:28:31 +02:00
const fetchFollowers = ({ id, maxId, sinceId, limit }) => {
return apiService.fetchFollowers({ id, maxId, sinceId, limit, credentials })
2016-11-30 21:27:25 +01:00
}
2019-06-18 22:28:31 +02:00
const fetchUser = ({ id }) => {
return apiService.fetchUser({ id, credentials })
}
2019-06-18 22:28:31 +02:00
const fetchUserRelationship = ({ id }) => {
return apiService.fetchUserRelationship({ id, credentials })
}
const followUser = ({ id, reblogs }) => {
return apiService.followUser({ credentials, id, reblogs })
2016-12-08 09:09:21 +01:00
}
2016-12-23 16:45:57 +01:00
const unfollowUser = (id) => {
2019-06-18 22:28:31 +02:00
return apiService.unfollowUser({ credentials, id })
2016-12-23 16:45:57 +01:00
}
2017-11-07 21:38:28 +01:00
const blockUser = (id) => {
2019-06-18 22:28:31 +02:00
return apiService.blockUser({ credentials, id })
2017-11-07 21:38:28 +01:00
}
const unblockUser = (id) => {
2019-06-18 22:28:31 +02:00
return apiService.unblockUser({ credentials, id })
2017-11-07 21:38:28 +01:00
}
const approveUser = (id) => {
2019-06-18 22:28:31 +02:00
return apiService.approveUser({ credentials, id })
}
const denyUser = (id) => {
2019-06-18 22:28:31 +02:00
return apiService.denyUser({ credentials, id })
}
2019-04-04 18:03:56 +02:00
const startFetchingTimeline = ({ timeline, store, userId = false, tag }) => {
return timelineFetcherService.startFetching({ timeline, store, credentials, userId, tag })
}
const startFetchingNotifications = ({ store }) => {
return notificationsFetcher.startFetching({ store, credentials })
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const tagUser = ({ screen_name }, tag) => {
return apiService.tagUser({ screen_name, tag, credentials })
2019-02-18 15:49:32 +01:00
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const untagUser = ({ screen_name }, tag) => {
return apiService.untagUser({ screen_name, tag, credentials })
2019-02-18 15:49:32 +01:00
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const addRight = ({ screen_name }, right) => {
return apiService.addRight({ screen_name, right, credentials })
2019-02-18 15:49:32 +01:00
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const deleteRight = ({ screen_name }, right) => {
return apiService.deleteRight({ screen_name, right, credentials })
2019-02-18 15:49:32 +01:00
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const setActivationStatus = ({ screen_name }, status) => {
return apiService.setActivationStatus({ screen_name, status, credentials })
2019-02-18 15:49:32 +01:00
}
2019-07-06 23:54:17 +02:00
// eslint-disable-next-line camelcase
2019-06-18 22:28:31 +02:00
const deleteUser = ({ screen_name }) => {
return apiService.deleteUser({ screen_name, credentials })
2019-02-18 15:49:32 +01:00
}
2019-06-18 22:28:31 +02:00
const vote = (pollId, choices) => {
return apiService.vote({ credentials, pollId, choices })
2019-05-25 09:01:02 +02:00
}
2019-06-18 22:28:31 +02:00
const fetchPoll = (pollId) => {
return apiService.fetchPoll({ credentials, pollId })
}
const updateNotificationSettings = ({ settings }) => {
return apiService.updateNotificationSettings({ credentials, settings })
}
const fetchMutes = () => apiService.fetchMutes({ credentials })
const muteUser = (id) => apiService.muteUser({ credentials, id })
const unmuteUser = (id) => apiService.unmuteUser({ credentials, id })
const subscribeUser = (id) => apiService.subscribeUser({ credentials, id })
const unsubscribeUser = (id) => apiService.unsubscribeUser({ credentials, id })
2019-06-18 22:28:31 +02:00
const fetchBlocks = () => apiService.fetchBlocks({ credentials })
const fetchFollowRequests = () => apiService.fetchFollowRequests({ credentials })
const fetchOAuthTokens = () => apiService.fetchOAuthTokens({ credentials })
const revokeOAuthToken = (id) => apiService.revokeOAuthToken({ id, credentials })
const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id })
const pinOwnStatus = (id) => apiService.pinOwnStatus({ credentials, id })
const unpinOwnStatus = (id) => apiService.unpinOwnStatus({ credentials, id })
const muteConversation = (id) => apiService.muteConversation({ credentials, id })
const unmuteConversation = (id) => apiService.unmuteConversation({ credentials, id })
const getCaptcha = () => apiService.getCaptcha()
const register = (params) => apiService.register({ credentials, params })
2019-06-18 22:28:31 +02:00
const updateAvatar = ({ avatar }) => apiService.updateAvatar({ credentials, avatar })
const updateBg = ({ background }) => apiService.updateBg({ credentials, background })
2019-06-18 22:28:31 +02:00
const updateBanner = ({ banner }) => apiService.updateBanner({ credentials, banner })
const updateProfile = ({ params }) => apiService.updateProfile({ credentials, params })
const importBlocks = (file) => apiService.importBlocks({ file, credentials })
const importFollows = (file) => apiService.importFollows({ file, credentials })
2017-04-15 18:12:23 +02:00
2019-06-18 22:28:31 +02:00
const deleteAccount = ({ password }) => apiService.deleteAccount({ credentials, password })
2019-11-08 03:21:19 +01:00
const changeEmail = ({ email, password }) => apiService.changeEmail({ credentials, email, password })
2019-06-18 22:28:31 +02:00
const changePassword = ({ password, newPassword, newPasswordConfirmation }) =>
apiService.changePassword({ credentials, password, newPassword, newPasswordConfirmation })
2019-06-18 22:28:31 +02:00
const fetchSettingsMFA = () => apiService.settingsMFA({ credentials })
const generateMfaBackupCodes = () => apiService.generateMfaBackupCodes({ credentials })
const mfaSetupOTP = () => apiService.mfaSetupOTP({ credentials })
const mfaConfirmOTP = ({ password, token }) => apiService.mfaConfirmOTP({ credentials, password, token })
const mfaDisableOTP = ({ password }) => apiService.mfaDisableOTP({ credentials, password })
2019-06-18 22:28:31 +02:00
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })
const reportUser = (params) => apiService.reportUser({ credentials, ...params })
2019-04-02 04:30:06 +02:00
2019-06-18 22:28:31 +02:00
const favorite = (id) => apiService.favorite({ id, credentials })
const unfavorite = (id) => apiService.unfavorite({ id, credentials })
const retweet = (id) => apiService.retweet({ id, credentials })
const unretweet = (id) => apiService.unretweet({ id, credentials })
2019-07-15 18:42:27 +02:00
const search2 = ({ q, resolve, limit, offset, following }) =>
apiService.search2({ credentials, q, resolve, limit, offset, following })
const searchUsers = (query) => apiService.searchUsers({ query, credentials })
2019-05-08 05:36:35 +02:00
const backendInteractorServiceInstance = {
fetchStatus,
2016-11-26 19:12:09 +01:00
fetchConversation,
2016-11-30 21:27:25 +01:00
fetchFriends,
exportFriends,
2017-08-21 19:25:01 +02:00
fetchFollowers,
2016-12-08 09:09:21 +01:00
followUser,
2016-12-23 16:45:57 +01:00
unfollowUser,
2017-11-07 21:38:28 +01:00
blockUser,
unblockUser,
fetchUser,
fetchUserRelationship,
verifyCredentials: apiService.verifyCredentials,
2019-04-04 18:03:56 +02:00
startFetchingTimeline,
startFetchingNotifications,
2017-04-15 18:12:23 +02:00
fetchMutes,
muteUser,
unmuteUser,
subscribeUser,
unsubscribeUser,
2019-02-13 18:05:23 +01:00
fetchBlocks,
fetchOAuthTokens,
revokeOAuthToken,
fetchPinnedStatuses,
2019-04-25 03:56:09 +02:00
pinOwnStatus,
unpinOwnStatus,
muteConversation,
unmuteConversation,
2019-02-18 15:49:32 +01:00
tagUser,
untagUser,
addRight,
deleteRight,
deleteUser,
setActivationStatus,
2017-04-16 13:44:11 +02:00
register,
getCaptcha,
2017-06-19 10:32:40 +02:00
updateAvatar,
updateBg,
updateBanner,
updateProfile,
2019-03-30 12:27:53 +01:00
importBlocks,
2019-03-30 12:22:30 +01:00
importFollows,
2018-05-22 00:01:09 +02:00
deleteAccount,
2019-11-08 03:21:19 +01:00
changeEmail,
changePassword,
fetchSettingsMFA,
generateMfaBackupCodes,
mfaSetupOTP,
mfaConfirmOTP,
mfaDisableOTP,
fetchFollowRequests,
approveUser,
2019-04-02 04:29:45 +02:00
denyUser,
2019-06-18 22:28:31 +02:00
vote,
fetchPoll,
2019-04-02 18:13:55 +02:00
fetchFavoritedByUsers,
2019-03-20 16:45:19 +01:00
fetchRebloggedByUsers,
2019-05-08 05:36:35 +02:00
reportUser,
favorite,
unfavorite,
retweet,
2019-05-25 09:01:02 +02:00
unretweet,
updateNotificationSettings,
search2,
searchUsers
}
return backendInteractorServiceInstance
}
export default backendInteractorService