-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ban): add endpoints for ban handling
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import axios from '@nextcloud/axios' | ||
import { generateOcsUrl } from '@nextcloud/router' | ||
|
||
import type { | ||
getBansResponse, | ||
banActorParams, | ||
banActorResponse, | ||
unbanActorParams, | ||
unbanActorResponse, | ||
} from '../types' | ||
|
||
/** | ||
* Get information about configured bans for this conversation | ||
* | ||
* @param token - the conversation token | ||
* @param [options] - request options | ||
*/ | ||
const getConversationBans = async function(token: string, options?: object): getBansResponse { | ||
return axios.get(generateOcsUrl('/apps/spreed/api/v1/ban/{token}', { token }, options), options) | ||
} | ||
|
||
/** | ||
* Ban actor with specified internal note for this conversation | ||
* | ||
* @param token - the conversation token | ||
* @param payload - banned actor information | ||
* @param [options] - request options | ||
*/ | ||
const banActor = async function(token: string, payload: banActorParams, options?: object): banActorResponse { | ||
return axios.post(generateOcsUrl('/apps/spreed/api/v1/ban/{token}', { token }, options), payload, options) | ||
} | ||
|
||
/** | ||
* Ban actor with specified internal note for this conversation | ||
* | ||
* @param token - the conversation token | ||
* @param banId - ban id | ||
* @param [options] - request options | ||
*/ | ||
const unbanActor = async function(token: string, banId: unbanActorParams['banId'], options?: object): unbanActorResponse { | ||
return axios.delete(generateOcsUrl('/apps/spreed/api/v1/ban/{token}', { token }, options), { | ||
...options, | ||
params: { banId } as unbanActorParams, | ||
}) | ||
} | ||
|
||
export { | ||
getConversationBans, | ||
banActor, | ||
unbanActor, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters