2018-04-28 14:19:39 -07:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { approveFollowRequest, rejectFollowRequest } from '../_api/requests'
|
|
|
|
import { emit } from '../_utils/eventBus'
|
2018-12-22 15:37:51 -08:00
|
|
|
import { toast } from '../_components/toast/toast'
|
2018-04-28 14:19:39 -07:00
|
|
|
|
|
|
|
export async function setFollowRequestApprovedOrRejected (accountId, approved, toastOnSuccess) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const {
|
2018-04-28 14:19:39 -07:00
|
|
|
currentInstance,
|
|
|
|
accessToken
|
|
|
|
} = store.get()
|
|
|
|
try {
|
|
|
|
if (approved) {
|
|
|
|
await approveFollowRequest(currentInstance, accessToken, accountId)
|
|
|
|
} else {
|
|
|
|
await rejectFollowRequest(currentInstance, accessToken, accountId)
|
|
|
|
}
|
|
|
|
if (toastOnSuccess) {
|
|
|
|
if (approved) {
|
|
|
|
toast.say('Approved follow request')
|
|
|
|
} else {
|
|
|
|
toast.say('Rejected follow request')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emit('refreshAccountsList')
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
toast.say(`Unable to ${approved ? 'approve' : 'reject'} account: ` + (e.message || ''))
|
|
|
|
}
|
|
|
|
}
|