mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-27 13:45:27 -05:00
Short link feature
This commit is contained in:
@@ -48,6 +48,11 @@ const PERKS = [
|
||||
name: "prioritySupport",
|
||||
extraInfo: true,
|
||||
},
|
||||
{
|
||||
tier: 2,
|
||||
name: "userShortLink",
|
||||
extraInfo: true,
|
||||
},
|
||||
{
|
||||
tier: 2,
|
||||
name: "customizedColorsUser",
|
||||
|
||||
@@ -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")
|
||||
|
||||
15
app/features/user-page/routes/short.$customUrl.tsx
Normal file
15
app/features/user-page/routes/short.$customUrl.tsx
Normal 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));
|
||||
};
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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", [
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user