FEATURE: add transformer to pass topic ID to simple invite generation (#29861)

This commit is contained in:
Kris 2024-11-20 16:08:08 -05:00 committed by GitHub
parent 23a7f00524
commit 9db6bd08a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import FutureDateInput from "discourse/components/future-date-input";
import { extractError } from "discourse/lib/ajax-error";
import { canNativeShare, nativeShare } from "discourse/lib/pwa-utils";
import { sanitize } from "discourse/lib/text";
import { applyValueTransformer } from "discourse/lib/transformer";
import { emailValid, hostnameValid } from "discourse/lib/utilities";
import Group from "discourse/models/group";
import Invite from "discourse/models/invite";
@ -248,11 +249,17 @@ export default class CreateInvite extends Component {
@action
async createLink() {
this.sendEmail = false;
const topicId = applyValueTransformer("invite-simple-mode-topic", null, {
invite: this.invite,
});
await this.save({
max_redemptions_allowed: this.defaultRedemptionsAllowed,
expires_at: moment()
.add(this.siteSettings.invite_expiry_days, "days")
.format(DATE_INPUT_FORMAT),
...(topicId != null && { topic_id: topicId }),
});
}

View File

@ -10,6 +10,7 @@ export const VALUE_TRANSFORMERS = Object.freeze([
"header-notifications-avatar-size",
"home-logo-href",
"home-logo-image-url",
"invite-simple-mode-topic",
"mentions-class",
"more-topics-tabs",
"post-menu-buttons",