mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
invites: add "User Label" 1/2
Adds a "User Label" invite field, which is a label applied to users created with it. This commit contains everything apart from the code to apply it on account creation.
This commit is contained in:
parent
4ea2dfdfb7
commit
7c76b58ab8
@ -161,6 +161,9 @@ func (app *appContext) GenerateInvite(gc *gin.Context) {
|
|||||||
if req.Label != "" {
|
if req.Label != "" {
|
||||||
invite.Label = req.Label
|
invite.Label = req.Label
|
||||||
}
|
}
|
||||||
|
if req.UserLabel != "" {
|
||||||
|
invite.UserLabel = req.UserLabel
|
||||||
|
}
|
||||||
invite.Created = currentTime
|
invite.Created = currentTime
|
||||||
if req.MultipleUses {
|
if req.MultipleUses {
|
||||||
if req.NoLimit {
|
if req.NoLimit {
|
||||||
@ -261,6 +264,7 @@ func (app *appContext) GetInvites(gc *gin.Context) {
|
|||||||
Profile: inv.Profile,
|
Profile: inv.Profile,
|
||||||
NoLimit: inv.NoLimit,
|
NoLimit: inv.NoLimit,
|
||||||
Label: inv.Label,
|
Label: inv.Label,
|
||||||
|
UserLabel: inv.UserLabel,
|
||||||
}
|
}
|
||||||
if len(inv.UsedBy) != 0 {
|
if len(inv.UsedBy) != 0 {
|
||||||
invite.UsedBy = map[string]int64{}
|
invite.UsedBy = map[string]int64{}
|
||||||
|
@ -589,6 +589,11 @@
|
|||||||
<label class="label supra" for="create-label"> {{ .strings.label }}</label>
|
<label class="label supra" for="create-label"> {{ .strings.label }}</label>
|
||||||
<input type="text" id="create-label" class="input ~neutral @low mb-2 mt-4">
|
<input type="text" id="create-label" class="input ~neutral @low mb-2 mt-4">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<label class="label supra" for="create-user-label"> {{ .strings.userLabel }}</label>
|
||||||
|
<p class="support">{{ .strings.userLabelDescription }}</p>
|
||||||
|
<input type="text" id="create-user-label" class="input ~neutral @low mb-2 mt-4">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card ~neutral @low col">
|
<div class="card ~neutral @low col">
|
||||||
<label class="label supra" for="create-uses">{{ .strings.inviteNumberOfUses }}</label>
|
<label class="label supra" for="create-uses">{{ .strings.inviteNumberOfUses }}</label>
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
"profile": "Profile",
|
"profile": "Profile",
|
||||||
"unknown": "Unknown",
|
"unknown": "Unknown",
|
||||||
"label": "Label",
|
"label": "Label",
|
||||||
|
"userLabel": "User Label",
|
||||||
|
"userLabelDescription": "Label to apply to users created with this invite.",
|
||||||
"logs": "Logs",
|
"logs": "Logs",
|
||||||
"announce": "Announce",
|
"announce": "Announce",
|
||||||
"templates": "Templates",
|
"templates": "Templates",
|
||||||
|
@ -63,6 +63,7 @@ type generateInviteDTO struct {
|
|||||||
RemainingUses int `json:"remaining-uses" example:"5"` // Remaining invite uses
|
RemainingUses int `json:"remaining-uses" example:"5"` // Remaining invite uses
|
||||||
Profile string `json:"profile" example:"DefaultProfile"` // Name of profile to apply on this invite
|
Profile string `json:"profile" example:"DefaultProfile"` // Name of profile to apply on this invite
|
||||||
Label string `json:"label" example:"For Friends"` // Optional label for the invite
|
Label string `json:"label" example:"For Friends"` // Optional label for the invite
|
||||||
|
UserLabel string `json:"user_label,omitempty" example:"Friend"` // Label to apply to users created w/ this invite.
|
||||||
}
|
}
|
||||||
|
|
||||||
type inviteProfileDTO struct {
|
type inviteProfileDTO struct {
|
||||||
@ -114,6 +115,7 @@ type inviteDTO struct {
|
|||||||
NotifyExpiry bool `json:"notify-expiry,omitempty"` // Whether to notify the requesting user of expiry or not
|
NotifyExpiry bool `json:"notify-expiry,omitempty"` // Whether to notify the requesting user of expiry or not
|
||||||
NotifyCreation bool `json:"notify-creation,omitempty"` // Whether to notify the requesting user of account creation or not
|
NotifyCreation bool `json:"notify-creation,omitempty"` // Whether to notify the requesting user of account creation or not
|
||||||
Label string `json:"label,omitempty" example:"For Friends"` // Optional label for the invite
|
Label string `json:"label,omitempty" example:"For Friends"` // Optional label for the invite
|
||||||
|
UserLabel string `json:"user_label,omitempty" example:"Friend"` // Label to apply to users created w/ this invite.
|
||||||
}
|
}
|
||||||
|
|
||||||
type getInvitesDTO struct {
|
type getInvitesDTO struct {
|
||||||
|
@ -500,6 +500,7 @@ type Invite struct {
|
|||||||
Notify map[string]map[string]bool `json:"notify"`
|
Notify map[string]map[string]bool `json:"notify"`
|
||||||
Profile string `json:"profile"`
|
Profile string `json:"profile"`
|
||||||
Label string `json:"label,omitempty"`
|
Label string `json:"label,omitempty"`
|
||||||
|
UserLabel string `json:"user_label,omitempty" example:"Friend"` // Label to apply to users created w/ this invite.
|
||||||
Captchas map[string]Captcha // Map of Captcha IDs to images & answers
|
Captchas map[string]Captcha // Map of Captcha IDs to images & answers
|
||||||
IsReferral bool `json:"is_referral" badgerhold:"index"`
|
IsReferral bool `json:"is_referral" badgerhold:"index"`
|
||||||
ReferrerJellyfinID string `json:"referrer_id"`
|
ReferrerJellyfinID string `json:"referrer_id"`
|
||||||
|
@ -39,6 +39,21 @@ class DOMInvite implements Invite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _userLabel: string = "";
|
||||||
|
get user_label(): string { return this._userLabel; }
|
||||||
|
set user_label(label: string) {
|
||||||
|
this._userLabel = label;
|
||||||
|
const labelLabel = this._middle.querySelector(".user-label-label");
|
||||||
|
const value = this._middle.querySelector(".user-label");
|
||||||
|
if (label) {
|
||||||
|
labelLabel.textContent = window.lang.strings("userLabel");
|
||||||
|
value.textContent = label;
|
||||||
|
} else {
|
||||||
|
labelLabel.textContent = "";
|
||||||
|
value.textContent = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _code: string = "None";
|
private _code: string = "None";
|
||||||
get code(): string { return this._code; }
|
get code(): string { return this._code; }
|
||||||
set code(code: string) {
|
set code(code: string) {
|
||||||
@ -351,6 +366,7 @@ class DOMInvite implements Invite {
|
|||||||
<p class="supra mb-4 top">${window.lang.strings("inviteDateCreated")} <strong class="inv-created"></strong></p>
|
<p class="supra mb-4 top">${window.lang.strings("inviteDateCreated")} <strong class="inv-created"></strong></p>
|
||||||
<p class="supra mb-4">${window.lang.strings("inviteRemainingUses")} <strong class="inv-remaining"></strong></p>
|
<p class="supra mb-4">${window.lang.strings("inviteRemainingUses")} <strong class="inv-remaining"></strong></p>
|
||||||
<p class="supra mb-4"><span class="user-expiry"></span> <strong class="user-expiry-time"></strong></p>
|
<p class="supra mb-4"><span class="user-expiry"></span> <strong class="user-expiry-time"></strong></p>
|
||||||
|
<p class="mb-4 flex items-center"><span class="user-label-label supra mr-2"></span> <span class="user-label chip ~blue"></span></p>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
this._right = document.createElement('div') as HTMLDivElement;
|
this._right = document.createElement('div') as HTMLDivElement;
|
||||||
@ -386,6 +402,9 @@ class DOMInvite implements Invite {
|
|||||||
if (invite.label) {
|
if (invite.label) {
|
||||||
this.label = invite.label;
|
this.label = invite.label;
|
||||||
}
|
}
|
||||||
|
if (invite.user_label) {
|
||||||
|
this.user_label = invite.user_label;
|
||||||
|
}
|
||||||
this.userExpiryTime = invite.userExpiryTime || "";
|
this.userExpiryTime = invite.userExpiryTime || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,6 +505,7 @@ function parseInvite(invite: { [f: string]: string | number | { [name: string]:
|
|||||||
parsed.code = invite["code"] as string;
|
parsed.code = invite["code"] as string;
|
||||||
parsed.send_to = invite["send_to"] as string || "";
|
parsed.send_to = invite["send_to"] as string || "";
|
||||||
parsed.label = invite["label"] as string || "";
|
parsed.label = invite["label"] as string || "";
|
||||||
|
parsed.user_label = invite["user_label"] as string || "";
|
||||||
let time = "";
|
let time = "";
|
||||||
let userExpiryTime = "";
|
let userExpiryTime = "";
|
||||||
const fields = ["months", "days", "hours", "minutes"];
|
const fields = ["months", "days", "hours", "minutes"];
|
||||||
@ -530,6 +550,7 @@ export class createInvite {
|
|||||||
private _createButton = document.getElementById("create-submit") as HTMLSpanElement;
|
private _createButton = document.getElementById("create-submit") as HTMLSpanElement;
|
||||||
private _profile = document.getElementById("create-profile") as HTMLSelectElement;
|
private _profile = document.getElementById("create-profile") as HTMLSelectElement;
|
||||||
private _label = document.getElementById("create-label") as HTMLInputElement;
|
private _label = document.getElementById("create-label") as HTMLInputElement;
|
||||||
|
private _userLabel = document.getElementById("create-user-label") as HTMLInputElement;
|
||||||
|
|
||||||
private _months = document.getElementById("create-months") as HTMLSelectElement;
|
private _months = document.getElementById("create-months") as HTMLSelectElement;
|
||||||
private _days = document.getElementById("create-days") as HTMLSelectElement;
|
private _days = document.getElementById("create-days") as HTMLSelectElement;
|
||||||
@ -572,6 +593,9 @@ export class createInvite {
|
|||||||
get label(): string { return this._label.value; }
|
get label(): string { return this._label.value; }
|
||||||
set label(label: string) { this._label.value = label; }
|
set label(label: string) { this._label.value = label; }
|
||||||
|
|
||||||
|
get user_label(): string { return this._userLabel.value; }
|
||||||
|
set user_label(label: string) { this._userLabel.value = label; }
|
||||||
|
|
||||||
get sendToEnabled(): boolean {
|
get sendToEnabled(): boolean {
|
||||||
return this._sendToEnabled.checked;
|
return this._sendToEnabled.checked;
|
||||||
}
|
}
|
||||||
@ -749,7 +773,8 @@ export class createInvite {
|
|||||||
"remaining-uses": this.uses,
|
"remaining-uses": this.uses,
|
||||||
"send-to": this.sendToEnabled ? this.sendTo : "",
|
"send-to": this.sendToEnabled ? this.sendTo : "",
|
||||||
"profile": this.profile,
|
"profile": this.profile,
|
||||||
"label": this.label
|
"label": this.label,
|
||||||
|
"user_label": this.user_label
|
||||||
};
|
};
|
||||||
_post("/invites", send, (req: XMLHttpRequest) => {
|
_post("/invites", send, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
|
@ -129,6 +129,7 @@ interface Invite {
|
|||||||
notifyCreation?: boolean;
|
notifyCreation?: boolean;
|
||||||
profile?: string;
|
profile?: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
user_label?: string;
|
||||||
userExpiry?: boolean;
|
userExpiry?: boolean;
|
||||||
userExpiryTime?: string;
|
userExpiryTime?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user