mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 06:48:07 -06:00
[feature] Allow editing domain blocks/allows, fix comment import
This commit is contained in:
parent
7d253550b3
commit
e856d09f8e
13 changed files with 320 additions and 181 deletions
|
|
@ -40,39 +40,19 @@ function importEntriesProcessor(formData: ImportDomainPermsParams): (_entry: Dom
|
|||
|
||||
// Override each obfuscate entry if necessary.
|
||||
if (formData.obfuscate !== undefined) {
|
||||
const obfuscateEntry = (entry: DomainPerm) => {
|
||||
processingFuncs.push((entry: DomainPerm) => {
|
||||
entry.obfuscate = formData.obfuscate;
|
||||
};
|
||||
processingFuncs.push(obfuscateEntry);
|
||||
});
|
||||
}
|
||||
|
||||
// Check whether we need to append or replace
|
||||
// private_comment and public_comment.
|
||||
// Check whether we need to replace
|
||||
// private_comment and/or public_comment.
|
||||
["private_comment","public_comment"].forEach((commentType) => {
|
||||
let text = formData.commentType?.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(formData[`${commentType}_behavior`]) {
|
||||
case "append":
|
||||
const appendComment = (entry: DomainPerm) => {
|
||||
if (entry.commentType == undefined) {
|
||||
entry.commentType = text;
|
||||
} else {
|
||||
entry.commentType = [entry.commentType, text].join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
processingFuncs.push(appendComment);
|
||||
break;
|
||||
case "replace":
|
||||
const replaceComment = (entry: DomainPerm) => {
|
||||
entry.commentType = text;
|
||||
};
|
||||
|
||||
processingFuncs.push(replaceComment);
|
||||
break;
|
||||
if (formData[`replace_${commentType}`]) {
|
||||
const text = formData[commentType]?.trim();
|
||||
processingFuncs.push((entry: DomainPerm) => {
|
||||
entry[commentType] = text;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ const extended = gtsApi.injectEndpoints({
|
|||
}),
|
||||
|
||||
updateDomainBlock: build.mutation<DomainPerm, any>({
|
||||
query: (formData) => ({
|
||||
query: ({ id, ...formData}) => ({
|
||||
method: "PUT",
|
||||
url: `/api/v1/admin/domain_blocks/${formData.id}`,
|
||||
url: `/api/v1/admin/domain_blocks/${id}`,
|
||||
asForm: true,
|
||||
body: formData,
|
||||
discardEmpty: false
|
||||
|
|
@ -72,9 +72,9 @@ const extended = gtsApi.injectEndpoints({
|
|||
}),
|
||||
|
||||
updateDomainAllow: build.mutation<DomainPerm, any>({
|
||||
query: (formData) => ({
|
||||
query: ({ id, ...formData}) => ({
|
||||
method: "PUT",
|
||||
url: `/api/v1/admin/domain_allows/${formData.id}`,
|
||||
url: `/api/v1/admin/domain_allows/${id}`,
|
||||
asForm: true,
|
||||
body: formData,
|
||||
discardEmpty: false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue