forked from AkkomaGang/akkoma-fe
Backend Interactor service overhaul, removed the need for copypasting
This commit is contained in:
parent
41d2fa2fd6
commit
ddb6fb9217
10 changed files with 55 additions and 256 deletions
|
@ -7,11 +7,11 @@ const FollowRequestCard = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
approveUser () {
|
approveUser () {
|
||||||
this.$store.state.api.backendInteractor.approveUser(this.user.id)
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
||||||
this.$store.dispatch('removeFollowRequest', this.user)
|
this.$store.dispatch('removeFollowRequest', this.user)
|
||||||
},
|
},
|
||||||
denyUser () {
|
denyUser () {
|
||||||
this.$store.state.api.backendInteractor.denyUser(this.user.id)
|
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
|
||||||
this.$store.dispatch('removeFollowRequest', this.user)
|
this.$store.dispatch('removeFollowRequest', this.user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ const ModerationTools = {
|
||||||
toggleTag (tag) {
|
toggleTag (tag) {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
if (this.tagsSet.has(tag)) {
|
if (this.tagsSet.has(tag)) {
|
||||||
store.state.api.backendInteractor.untagUser(this.user, tag).then(response => {
|
store.state.api.backendInteractor.untagUser({ user: this.user, tag }).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('untagUser', { user: this.user, tag })
|
store.commit('untagUser', { user: this.user, tag })
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
store.state.api.backendInteractor.tagUser(this.user, tag).then(response => {
|
store.state.api.backendInteractor.tagUser({ user: this.user, tag }).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('tagUser', { user: this.user, tag })
|
store.commit('tagUser', { user: this.user, tag })
|
||||||
})
|
})
|
||||||
|
@ -59,21 +59,21 @@ const ModerationTools = {
|
||||||
toggleRight (right) {
|
toggleRight (right) {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
if (this.user.rights[right]) {
|
if (this.user.rights[right]) {
|
||||||
store.state.api.backendInteractor.deleteRight(this.user, right).then(response => {
|
store.state.api.backendInteractor.deleteRight({ user: this.user, right }).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateRight', { user: this.user, right: right, value: false })
|
store.commit('updateRight', { user: this.user, right, value: false })
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
store.state.api.backendInteractor.addRight(this.user, right).then(response => {
|
store.state.api.backendInteractor.addRight({ user: this.user, right }).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateRight', { user: this.user, right: right, value: true })
|
store.commit('updateRight', { user: this.user, right, value: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleActivationStatus () {
|
toggleActivationStatus () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const status = !!this.user.deactivated
|
const status = !!this.user.deactivated
|
||||||
store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => {
|
store.state.api.backendInteractor.setActivationStatus({ user: this.user, status }).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateActivationStatus', { user: this.user, status: status })
|
store.commit('updateActivationStatus', { user: this.user, status: status })
|
||||||
})
|
})
|
||||||
|
@ -85,7 +85,7 @@ const ModerationTools = {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const user = this.user
|
const user = this.user
|
||||||
const { id, name } = user
|
const { id, name } = user
|
||||||
store.state.api.backendInteractor.deleteUser(user)
|
store.state.api.backendInteractor.deleteUser({ user })
|
||||||
.then(e => {
|
.then(e => {
|
||||||
this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)
|
this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)
|
||||||
const isProfile = this.$route.name === 'external-user-profile' || this.$route.name === 'user-profile'
|
const isProfile = this.$route.name === 'external-user-profile' || this.$route.name === 'user-profile'
|
||||||
|
|
|
@ -64,7 +64,7 @@ const UserReportingModal = {
|
||||||
forward: this.forward,
|
forward: this.forward,
|
||||||
statusIds: this.statusIdsToReport
|
statusIds: this.statusIdsToReport
|
||||||
}
|
}
|
||||||
this.$store.state.api.backendInteractor.reportUser(params)
|
this.$store.state.api.backendInteractor.reportUser({ ...params })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.processing = false
|
this.processing = false
|
||||||
this.resetState()
|
this.resetState()
|
||||||
|
|
|
@ -242,7 +242,7 @@ const UserSettings = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
importFollows (file) {
|
importFollows (file) {
|
||||||
return this.$store.state.api.backendInteractor.importFollows(file)
|
return this.$store.state.api.backendInteractor.importFollows({ file })
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
|
@ -250,7 +250,7 @@ const UserSettings = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
importBlocks (file) {
|
importBlocks (file) {
|
||||||
return this.$store.state.api.backendInteractor.importBlocks(file)
|
return this.$store.state.api.backendInteractor.importBlocks({ file })
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
|
@ -297,7 +297,7 @@ const UserSettings = {
|
||||||
newPassword: this.changePasswordInputs[1],
|
newPassword: this.changePasswordInputs[1],
|
||||||
newPasswordConfirmation: this.changePasswordInputs[2]
|
newPasswordConfirmation: this.changePasswordInputs[2]
|
||||||
}
|
}
|
||||||
this.$store.state.api.backendInteractor.changePassword(params)
|
this.$store.state.api.backendInteractor.changePassword({ params })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.changedPassword = true
|
this.changedPassword = true
|
||||||
|
@ -314,7 +314,7 @@ const UserSettings = {
|
||||||
email: this.newEmail,
|
email: this.newEmail,
|
||||||
password: this.changeEmailPassword
|
password: this.changeEmailPassword
|
||||||
}
|
}
|
||||||
this.$store.state.api.backendInteractor.changeEmail(params)
|
this.$store.state.api.backendInteractor.changeEmail({ params })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.changedEmail = true
|
this.changedEmail = true
|
||||||
|
|
|
@ -9,7 +9,7 @@ const oauthTokens = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
revokeToken ({ rootState, commit, state }, id) {
|
revokeToken ({ rootState, commit, state }, id) {
|
||||||
rootState.api.backendInteractor.revokeOAuthToken(id).then((response) => {
|
rootState.api.backendInteractor.revokeOAuthToken({ id }).then((response) => {
|
||||||
if (response.status === 201) {
|
if (response.status === 201) {
|
||||||
commit('swapTokens', state.tokens.filter(token => token.id !== id))
|
commit('swapTokens', state.tokens.filter(token => token.id !== id))
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ const polls = {
|
||||||
commit('mergeOrAddPoll', poll)
|
commit('mergeOrAddPoll', poll)
|
||||||
},
|
},
|
||||||
updateTrackedPoll ({ rootState, dispatch, commit }, pollId) {
|
updateTrackedPoll ({ rootState, dispatch, commit }, pollId) {
|
||||||
rootState.api.backendInteractor.fetchPoll(pollId).then(poll => {
|
rootState.api.backendInteractor.fetchPoll({ pollId }).then(poll => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (rootState.polls.trackedPolls[pollId]) {
|
if (rootState.polls.trackedPolls[pollId]) {
|
||||||
dispatch('updateTrackedPoll', pollId)
|
dispatch('updateTrackedPoll', pollId)
|
||||||
|
@ -59,7 +59,7 @@ const polls = {
|
||||||
commit('untrackPoll', pollId)
|
commit('untrackPoll', pollId)
|
||||||
},
|
},
|
||||||
votePoll ({ rootState, commit }, { id, pollId, choices }) {
|
votePoll ({ rootState, commit }, { id, pollId, choices }) {
|
||||||
return rootState.api.backendInteractor.vote(pollId, choices).then(poll => {
|
return rootState.api.backendInteractor.vote({ pollId, choices }).then(poll => {
|
||||||
commit('mergeOrAddPoll', poll)
|
commit('mergeOrAddPoll', poll)
|
||||||
return poll
|
return poll
|
||||||
})
|
})
|
||||||
|
|
|
@ -551,45 +551,45 @@ const statuses = {
|
||||||
favorite ({ rootState, commit }, status) {
|
favorite ({ rootState, commit }, status) {
|
||||||
// Optimistic favoriting...
|
// Optimistic favoriting...
|
||||||
commit('setFavorited', { status, value: true })
|
commit('setFavorited', { status, value: true })
|
||||||
rootState.api.backendInteractor.favorite(status.id)
|
rootState.api.backendInteractor.favorite({ id: status.id })
|
||||||
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
|
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
unfavorite ({ rootState, commit }, status) {
|
unfavorite ({ rootState, commit }, status) {
|
||||||
// Optimistic unfavoriting...
|
// Optimistic unfavoriting...
|
||||||
commit('setFavorited', { status, value: false })
|
commit('setFavorited', { status, value: false })
|
||||||
rootState.api.backendInteractor.unfavorite(status.id)
|
rootState.api.backendInteractor.unfavorite({ id: status.id })
|
||||||
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
|
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
fetchPinnedStatuses ({ rootState, dispatch }, userId) {
|
fetchPinnedStatuses ({ rootState, dispatch }, userId) {
|
||||||
rootState.api.backendInteractor.fetchPinnedStatuses(userId)
|
rootState.api.backendInteractor.fetchPinnedStatuses({ id: userId })
|
||||||
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true }))
|
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true }))
|
||||||
},
|
},
|
||||||
pinStatus ({ rootState, dispatch }, statusId) {
|
pinStatus ({ rootState, dispatch }, statusId) {
|
||||||
return rootState.api.backendInteractor.pinOwnStatus(statusId)
|
return rootState.api.backendInteractor.pinOwnStatus({ id: statusId })
|
||||||
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
||||||
},
|
},
|
||||||
unpinStatus ({ rootState, dispatch }, statusId) {
|
unpinStatus ({ rootState, dispatch }, statusId) {
|
||||||
rootState.api.backendInteractor.unpinOwnStatus(statusId)
|
rootState.api.backendInteractor.unpinOwnStatus({ id: statusId })
|
||||||
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
||||||
},
|
},
|
||||||
muteConversation ({ rootState, commit }, statusId) {
|
muteConversation ({ rootState, commit }, statusId) {
|
||||||
return rootState.api.backendInteractor.muteConversation(statusId)
|
return rootState.api.backendInteractor.muteConversation({ id: statusId })
|
||||||
.then((status) => commit('setMutedStatus', status))
|
.then((status) => commit('setMutedStatus', status))
|
||||||
},
|
},
|
||||||
unmuteConversation ({ rootState, commit }, statusId) {
|
unmuteConversation ({ rootState, commit }, statusId) {
|
||||||
return rootState.api.backendInteractor.unmuteConversation(statusId)
|
return rootState.api.backendInteractor.unmuteConversation({ id: statusId })
|
||||||
.then((status) => commit('setMutedStatus', status))
|
.then((status) => commit('setMutedStatus', status))
|
||||||
},
|
},
|
||||||
retweet ({ rootState, commit }, status) {
|
retweet ({ rootState, commit }, status) {
|
||||||
// Optimistic retweeting...
|
// Optimistic retweeting...
|
||||||
commit('setRetweeted', { status, value: true })
|
commit('setRetweeted', { status, value: true })
|
||||||
rootState.api.backendInteractor.retweet(status.id)
|
rootState.api.backendInteractor.retweet({ id: status.id })
|
||||||
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
|
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
unretweet ({ rootState, commit }, status) {
|
unretweet ({ rootState, commit }, status) {
|
||||||
// Optimistic unretweeting...
|
// Optimistic unretweeting...
|
||||||
commit('setRetweeted', { status, value: false })
|
commit('setRetweeted', { status, value: false })
|
||||||
rootState.api.backendInteractor.unretweet(status.id)
|
rootState.api.backendInteractor.unretweet({ id: status.id })
|
||||||
.then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }))
|
.then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
queueFlush ({ rootState, commit }, { timeline, id }) {
|
queueFlush ({ rootState, commit }, { timeline, id }) {
|
||||||
|
@ -604,19 +604,19 @@ const statuses = {
|
||||||
},
|
},
|
||||||
fetchFavsAndRepeats ({ rootState, commit }, id) {
|
fetchFavsAndRepeats ({ rootState, commit }, id) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
rootState.api.backendInteractor.fetchFavoritedByUsers(id),
|
rootState.api.backendInteractor.fetchFavoritedByUsers({ id }),
|
||||||
rootState.api.backendInteractor.fetchRebloggedByUsers(id)
|
rootState.api.backendInteractor.fetchRebloggedByUsers({ id })
|
||||||
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
||||||
commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser })
|
commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser })
|
||||||
commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser })
|
commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchFavs ({ rootState, commit }, id) {
|
fetchFavs ({ rootState, commit }, id) {
|
||||||
rootState.api.backendInteractor.fetchFavoritedByUsers(id)
|
rootState.api.backendInteractor.fetchFavoritedByUsers({ id })
|
||||||
.then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser }))
|
.then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
fetchRepeats ({ rootState, commit }, id) {
|
fetchRepeats ({ rootState, commit }, id) {
|
||||||
rootState.api.backendInteractor.fetchRebloggedByUsers(id)
|
rootState.api.backendInteractor.fetchRebloggedByUsers({ id })
|
||||||
.then(rebloggedByUsers => commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser }))
|
.then(rebloggedByUsers => commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
search (store, { q, resolve, limit, offset, following }) {
|
search (store, { q, resolve, limit, offset, following }) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ const getNotificationPermission = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockUser = (store, id) => {
|
const blockUser = (store, id) => {
|
||||||
return store.rootState.api.backendInteractor.blockUser(id)
|
return store.rootState.api.backendInteractor.blockUser({ id })
|
||||||
.then((relationship) => {
|
.then((relationship) => {
|
||||||
store.commit('updateUserRelationship', [relationship])
|
store.commit('updateUserRelationship', [relationship])
|
||||||
store.commit('addBlockId', id)
|
store.commit('addBlockId', id)
|
||||||
|
@ -43,12 +43,12 @@ const blockUser = (store, id) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const unblockUser = (store, id) => {
|
const unblockUser = (store, id) => {
|
||||||
return store.rootState.api.backendInteractor.unblockUser(id)
|
return store.rootState.api.backendInteractor.unblockUser({ id })
|
||||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||||
}
|
}
|
||||||
|
|
||||||
const muteUser = (store, id) => {
|
const muteUser = (store, id) => {
|
||||||
return store.rootState.api.backendInteractor.muteUser(id)
|
return store.rootState.api.backendInteractor.muteUser({ id })
|
||||||
.then((relationship) => {
|
.then((relationship) => {
|
||||||
store.commit('updateUserRelationship', [relationship])
|
store.commit('updateUserRelationship', [relationship])
|
||||||
store.commit('addMuteId', id)
|
store.commit('addMuteId', id)
|
||||||
|
@ -56,7 +56,7 @@ const muteUser = (store, id) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const unmuteUser = (store, id) => {
|
const unmuteUser = (store, id) => {
|
||||||
return store.rootState.api.backendInteractor.unmuteUser(id)
|
return store.rootState.api.backendInteractor.unmuteUser({ id })
|
||||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,11 +324,11 @@ const users = {
|
||||||
commit('clearFollowers', userId)
|
commit('clearFollowers', userId)
|
||||||
},
|
},
|
||||||
subscribeUser ({ rootState, commit }, id) {
|
subscribeUser ({ rootState, commit }, id) {
|
||||||
return rootState.api.backendInteractor.subscribeUser(id)
|
return rootState.api.backendInteractor.subscribeUser({ id })
|
||||||
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
||||||
},
|
},
|
||||||
unsubscribeUser ({ rootState, commit }, id) {
|
unsubscribeUser ({ rootState, commit }, id) {
|
||||||
return rootState.api.backendInteractor.unsubscribeUser(id)
|
return rootState.api.backendInteractor.unsubscribeUser({ id })
|
||||||
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
.then((relationship) => commit('updateUserRelationship', [relationship]))
|
||||||
},
|
},
|
||||||
registerPushNotifications (store) {
|
registerPushNotifications (store) {
|
||||||
|
@ -382,7 +382,7 @@ const users = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
searchUsers (store, query) {
|
searchUsers (store, query) {
|
||||||
return store.rootState.api.backendInteractor.searchUsers(query)
|
return store.rootState.api.backendInteractor.searchUsers({ query })
|
||||||
.then((users) => {
|
.then((users) => {
|
||||||
store.commit('addNewUsers', users)
|
store.commit('addNewUsers', users)
|
||||||
return users
|
return users
|
||||||
|
@ -394,7 +394,7 @@ const users = {
|
||||||
let rootState = store.rootState
|
let rootState = store.rootState
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let data = await rootState.api.backendInteractor.register(userInfo)
|
let data = await rootState.api.backendInteractor.register({ ...userInfo })
|
||||||
store.commit('signUpSuccess')
|
store.commit('signUpSuccess')
|
||||||
store.commit('setToken', data.access_token)
|
store.commit('setToken', data.access_token)
|
||||||
store.dispatch('loginUser', data.access_token)
|
store.dispatch('loginUser', data.access_token)
|
||||||
|
|
|
@ -3,228 +3,27 @@ import timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service
|
||||||
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
||||||
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
||||||
|
|
||||||
const backendInteractorService = credentials => {
|
const backendInteractorService = credentials => ({
|
||||||
const fetchStatus = ({ id }) => {
|
startFetchingTimeline ({ timeline, store, userId = false, tag }) {
|
||||||
return apiService.fetchStatus({ id, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchConversation = ({ id }) => {
|
|
||||||
return apiService.fetchConversation({ id, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchFriends = ({ id, maxId, sinceId, limit }) => {
|
|
||||||
return apiService.fetchFriends({ id, maxId, sinceId, limit, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const exportFriends = ({ id }) => {
|
|
||||||
return apiService.exportFriends({ id, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchFollowers = ({ id, maxId, sinceId, limit }) => {
|
|
||||||
return apiService.fetchFollowers({ id, maxId, sinceId, limit, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchUser = ({ id }) => {
|
|
||||||
return apiService.fetchUser({ id, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchUserRelationship = ({ id }) => {
|
|
||||||
return apiService.fetchUserRelationship({ id, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const followUser = ({ id, reblogs }) => {
|
|
||||||
return apiService.followUser({ credentials, id, reblogs })
|
|
||||||
}
|
|
||||||
|
|
||||||
const unfollowUser = (id) => {
|
|
||||||
return apiService.unfollowUser({ credentials, id })
|
|
||||||
}
|
|
||||||
|
|
||||||
const blockUser = (id) => {
|
|
||||||
return apiService.blockUser({ credentials, id })
|
|
||||||
}
|
|
||||||
|
|
||||||
const unblockUser = (id) => {
|
|
||||||
return apiService.unblockUser({ credentials, id })
|
|
||||||
}
|
|
||||||
|
|
||||||
const approveUser = (id) => {
|
|
||||||
return apiService.approveUser({ credentials, id })
|
|
||||||
}
|
|
||||||
|
|
||||||
const denyUser = (id) => {
|
|
||||||
return apiService.denyUser({ credentials, id })
|
|
||||||
}
|
|
||||||
|
|
||||||
const startFetchingTimeline = ({ timeline, store, userId = false, tag }) => {
|
|
||||||
return timelineFetcherService.startFetching({ timeline, store, credentials, userId, tag })
|
return timelineFetcherService.startFetching({ timeline, store, credentials, userId, tag })
|
||||||
}
|
},
|
||||||
|
|
||||||
const startFetchingNotifications = ({ store }) => {
|
startFetchingNotifications ({ store }) {
|
||||||
return notificationsFetcher.startFetching({ store, credentials })
|
return notificationsFetcher.startFetching({ store, credentials })
|
||||||
}
|
},
|
||||||
|
|
||||||
const startFetchingFollowRequest = ({ store }) => {
|
startFetchingFollowRequest ({ store }) {
|
||||||
return followRequestFetcher.startFetching({ store, credentials })
|
return followRequestFetcher.startFetching({ store, credentials })
|
||||||
|
},
|
||||||
|
|
||||||
|
...Object.entries(apiService).reduce((acc, [key, func]) => {
|
||||||
|
return {
|
||||||
|
...acc,
|
||||||
|
[key]: (args) => func({ credentials, ...args })
|
||||||
}
|
}
|
||||||
|
}, {}),
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
verifyCredentials: apiService.verifyCredentials
|
||||||
const tagUser = ({ screen_name }, tag) => {
|
})
|
||||||
return apiService.tagUser({ screen_name, tag, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const untagUser = ({ screen_name }, tag) => {
|
|
||||||
return apiService.untagUser({ screen_name, tag, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const addRight = ({ screen_name }, right) => {
|
|
||||||
return apiService.addRight({ screen_name, right, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const deleteRight = ({ screen_name }, right) => {
|
|
||||||
return apiService.deleteRight({ screen_name, right, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const setActivationStatus = ({ screen_name }, status) => {
|
|
||||||
return apiService.setActivationStatus({ screen_name, status, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const deleteUser = ({ screen_name }) => {
|
|
||||||
return apiService.deleteUser({ screen_name, credentials })
|
|
||||||
}
|
|
||||||
|
|
||||||
const vote = (pollId, choices) => {
|
|
||||||
return apiService.vote({ credentials, pollId, choices })
|
|
||||||
}
|
|
||||||
|
|
||||||
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 })
|
|
||||||
const fetchBlocks = () => apiService.fetchBlocks({ 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 })
|
|
||||||
const updateAvatar = ({ avatar }) => apiService.updateAvatar({ credentials, avatar })
|
|
||||||
const updateBg = ({ background }) => apiService.updateBg({ credentials, background })
|
|
||||||
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 })
|
|
||||||
|
|
||||||
const deleteAccount = ({ password }) => apiService.deleteAccount({ credentials, password })
|
|
||||||
const changeEmail = ({ email, password }) => apiService.changeEmail({ credentials, email, password })
|
|
||||||
const changePassword = ({ password, newPassword, newPasswordConfirmation }) =>
|
|
||||||
apiService.changePassword({ credentials, password, newPassword, newPasswordConfirmation })
|
|
||||||
|
|
||||||
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 })
|
|
||||||
|
|
||||||
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })
|
|
||||||
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })
|
|
||||||
const reportUser = (params) => apiService.reportUser({ credentials, ...params })
|
|
||||||
|
|
||||||
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 })
|
|
||||||
const search2 = ({ q, resolve, limit, offset, following }) =>
|
|
||||||
apiService.search2({ credentials, q, resolve, limit, offset, following })
|
|
||||||
const searchUsers = (query) => apiService.searchUsers({ query, credentials })
|
|
||||||
|
|
||||||
const backendInteractorServiceInstance = {
|
|
||||||
fetchStatus,
|
|
||||||
fetchConversation,
|
|
||||||
fetchFriends,
|
|
||||||
exportFriends,
|
|
||||||
fetchFollowers,
|
|
||||||
followUser,
|
|
||||||
unfollowUser,
|
|
||||||
blockUser,
|
|
||||||
unblockUser,
|
|
||||||
fetchUser,
|
|
||||||
fetchUserRelationship,
|
|
||||||
verifyCredentials: apiService.verifyCredentials,
|
|
||||||
startFetchingTimeline,
|
|
||||||
startFetchingNotifications,
|
|
||||||
startFetchingFollowRequest,
|
|
||||||
fetchMutes,
|
|
||||||
muteUser,
|
|
||||||
unmuteUser,
|
|
||||||
subscribeUser,
|
|
||||||
unsubscribeUser,
|
|
||||||
fetchBlocks,
|
|
||||||
fetchOAuthTokens,
|
|
||||||
revokeOAuthToken,
|
|
||||||
fetchPinnedStatuses,
|
|
||||||
pinOwnStatus,
|
|
||||||
unpinOwnStatus,
|
|
||||||
muteConversation,
|
|
||||||
unmuteConversation,
|
|
||||||
tagUser,
|
|
||||||
untagUser,
|
|
||||||
addRight,
|
|
||||||
deleteRight,
|
|
||||||
deleteUser,
|
|
||||||
setActivationStatus,
|
|
||||||
register,
|
|
||||||
getCaptcha,
|
|
||||||
updateAvatar,
|
|
||||||
updateBg,
|
|
||||||
updateBanner,
|
|
||||||
updateProfile,
|
|
||||||
importBlocks,
|
|
||||||
importFollows,
|
|
||||||
deleteAccount,
|
|
||||||
changeEmail,
|
|
||||||
changePassword,
|
|
||||||
fetchSettingsMFA,
|
|
||||||
generateMfaBackupCodes,
|
|
||||||
mfaSetupOTP,
|
|
||||||
mfaConfirmOTP,
|
|
||||||
mfaDisableOTP,
|
|
||||||
approveUser,
|
|
||||||
denyUser,
|
|
||||||
vote,
|
|
||||||
fetchPoll,
|
|
||||||
fetchFavoritedByUsers,
|
|
||||||
fetchRebloggedByUsers,
|
|
||||||
reportUser,
|
|
||||||
favorite,
|
|
||||||
unfavorite,
|
|
||||||
retweet,
|
|
||||||
unretweet,
|
|
||||||
updateNotificationSettings,
|
|
||||||
search2,
|
|
||||||
searchUsers
|
|
||||||
}
|
|
||||||
|
|
||||||
return backendInteractorServiceInstance
|
|
||||||
}
|
|
||||||
|
|
||||||
export default backendInteractorService
|
export default backendInteractorService
|
||||||
|
|
|
@ -39,7 +39,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
export const requestUnfollow = (user, store) => new Promise((resolve, reject) => {
|
export const requestUnfollow = (user, store) => new Promise((resolve, reject) => {
|
||||||
store.state.api.backendInteractor.unfollowUser(user.id)
|
store.state.api.backendInteractor.unfollowUser({ id: user.id })
|
||||||
.then((updated) => {
|
.then((updated) => {
|
||||||
store.commit('updateUserRelationship', [updated])
|
store.commit('updateUserRelationship', [updated])
|
||||||
resolve({
|
resolve({
|
||||||
|
|
Loading…
Reference in a new issue