Short link feature
Some checks failed
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled

This commit is contained in:
Kalle
2024-12-26 11:37:14 +02:00
parent c418b8c44e
commit ca972ece84
7 changed files with 34 additions and 0 deletions

View File

@@ -48,6 +48,11 @@ const PERKS = [
name: "prioritySupport",
extraInfo: true,
},
{
tier: 2,
name: "userShortLink",
extraInfo: true,
},
{
tier: 2,
name: "customizedColorsUser",

View File

@@ -255,6 +255,14 @@ export async function findProfileByIdentifier(
};
}
export function findByCustomUrl(customUrl: string) {
return db
.selectFrom("User")
.select(["User.id", "User.discordId", "User.customUrl", "User.patronTier"])
.where("customUrl", "=", customUrl)
.executeTakeFirst();
}
export function findBannedStatusByUserId(userId: number) {
return db
.selectFrom("User")

View File

@@ -0,0 +1,15 @@
import type { LoaderFunction } from "@remix-run/node";
import { redirect } from "react-router-dom";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import { userPage } from "~/utils/urls";
import { isAtLeastFiveDollarTierPatreon } from "~/utils/users";
export const loader: LoaderFunction = async ({ params }) => {
const user = await UserRepository.findByCustomUrl(params.customUrl!);
if (!user || !isAtLeastFiveDollarTierPatreon(user)) {
return redirect("/");
}
return redirect(userPage(user));
};

View File

@@ -321,6 +321,7 @@ function CustomUrlInput({
maxLength={USER.CUSTOM_URL_MAX_LENGTH}
defaultValue={parentRouteData.user.customUrl ?? undefined}
/>
<FormMessage type="info">{t("user:forms.info.customUrl")}</FormMessage>
</div>
);
}

View File

@@ -227,6 +227,8 @@ export default [
route("/org/:id", "features/api-public/routes/org.$id.ts"),
]),
route("/short/:customUrl", "features/user-page/routes/short.$customUrl.tsx"),
route("/theme", "features/theme/routes/theme.ts"),
...prefix("/auth", [

View File

@@ -187,6 +187,8 @@
"support.perk.seePlusPercentage.extra": "Normally only failed suggests see their voting percentage. With this, you can always see your own percentage.",
"support.perk.autoValidatePictures": "Auto validate uploaded pictures",
"support.perk.autoValidatePictures.extra": "Any images you upload (e.g. team profile/banner picture) get automatically validated. Normally it needs a moderator's approval first. Note that this doesn't apply to images that were already submitted.",
"support.perk.userShortLink": "User page short link",
"support.perk.userShortLink.extra": "Instead of e.g. sendou.ink/u/sendou you can also use snd.ink/sendou when linking to your user profile.",
"support.perk.customizedColorsUser": "Customize colors (user page)",
"support.perk.customizedColorsTeam": "Customize colors (team page)",
"support.perk.customizedColorsTeam.extra": "It is enough that one member of the team is a patron to get this perk.",

View File

@@ -40,6 +40,7 @@
"forms.errors.invalidCustomUrl.strangeCharacter": "Custom URL can't contain special characters",
"forms.errors.invalidCustomUrl.duplicate": "Someone is already using this custom URL",
"forms.errors.invalidSens": "Motion sens can't be set if R-stick sens isn't",
"forms.info.customUrl": "For patrons (Supporter & above) short link is available. E.g. instead of sendou.ink/u/sendou, snd.ink/sendou can be used.",
"forms.info.favoriteBadge": "Your favorite badge is shown as big by default on your profile.",
"forms.info.battlefy": "Battlefy account name is used for seeding and verification in some tournaments",