feat: add support for anonymous posting
Hooks up the configuration API to allow posting threads anonymously.
This commit is contained in:
@@ -78,9 +78,23 @@ export async function getThread(threadId) {
|
||||
* @param {string} title
|
||||
* @param {string} content
|
||||
* @param {boolean} following Follow the thread after creating
|
||||
* @param {boolean} anonymous Should the thread be anonymous to all users
|
||||
* @param {boolean} anonymousToPeers Should the thread be anonymous to peers
|
||||
* @returns {Promise<{}>}
|
||||
*/
|
||||
export async function postThread(courseId, topicId, type, title, content, following = false, cohort) {
|
||||
export async function postThread(
|
||||
courseId,
|
||||
topicId,
|
||||
type,
|
||||
title,
|
||||
content,
|
||||
{
|
||||
following,
|
||||
cohort,
|
||||
anonymous,
|
||||
anonymousToPeers,
|
||||
} = {},
|
||||
) {
|
||||
const postData = snakeCaseObject({
|
||||
courseId,
|
||||
topicId,
|
||||
@@ -88,10 +102,13 @@ export async function postThread(courseId, topicId, type, title, content, follow
|
||||
title,
|
||||
raw_body: content,
|
||||
following,
|
||||
anonymous,
|
||||
anonymousToPeers,
|
||||
groupId: cohort,
|
||||
});
|
||||
|
||||
const { data } = await getAuthenticatedHttpClient().post(threadsApiUrl, postData);
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(threadsApiUrl, postData);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -146,7 +163,8 @@ export async function updateThread(threadId, {
|
||||
*/
|
||||
export async function deleteThread(threadId) {
|
||||
const url = `${threadsApiUrl}${threadId}/`;
|
||||
await getAuthenticatedHttpClient().delete(url);
|
||||
await getAuthenticatedHttpClient()
|
||||
.delete(url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,7 +170,9 @@ export function createNewThread({
|
||||
type,
|
||||
title,
|
||||
content,
|
||||
following = false,
|
||||
following,
|
||||
anonymous,
|
||||
anonymousToPeers,
|
||||
cohort,
|
||||
}) {
|
||||
return async (dispatch) => {
|
||||
@@ -182,9 +184,16 @@ export function createNewThread({
|
||||
title,
|
||||
content,
|
||||
following,
|
||||
anonymous,
|
||||
anonymousToPeers,
|
||||
cohort,
|
||||
}));
|
||||
const data = await postThread(courseId, topicId, type, title, content, following, cohort);
|
||||
const data = await postThread(courseId, topicId, type, title, content, {
|
||||
cohort,
|
||||
following,
|
||||
anonymous,
|
||||
anonymousToPeers,
|
||||
});
|
||||
dispatch(postThreadSuccess(camelCaseObject(data)));
|
||||
} catch (error) {
|
||||
if (getHttpErrorStatus(error) === 403) {
|
||||
|
||||
Reference in New Issue
Block a user