Skip to content

Commit

Permalink
feat: add share url alias /s
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Jul 22, 2023
1 parent 7827b68 commit 231a2e9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/src/email/email.service.ts
Expand Up @@ -54,7 +54,7 @@ export class EmailService {
if (!this.config.get("email.enableShareEmailRecipients"))
throw new InternalServerErrorException("Email service disabled");

const shareUrl = `${this.config.get("general.appUrl")}/share/${shareId}`;
const shareUrl = `${this.config.get("general.appUrl")}/s/${shareId}`;

await this.sendMail(
recipientEmail,
Expand All @@ -75,7 +75,7 @@ export class EmailService {
}

async sendMailToReverseShareCreator(recipientEmail: string, shareId: string) {
const shareUrl = `${this.config.get("general.appUrl")}/share/${shareId}`;
const shareUrl = `${this.config.get("general.appUrl")}/s/${shareId}`;

await this.sendMail(
recipientEmail,
Expand Down
Expand Up @@ -15,7 +15,7 @@ const showShareInformationsModal = (
maxShareSize: number
) => {
const t = translateOutsideContext();
const link = `${appUrl}/share/${share.id}`;
const link = `${appUrl}/s/${share.id}`;

let shareSize: number = 0;
for (let file of share.files as FileMetaData[])
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/account/showShareLinkModal.tsx
Expand Up @@ -8,7 +8,7 @@ const showShareLinkModal = (
appUrl: string
) => {
const t = translateOutsideContext();
const link = `${appUrl}/share/${shareId}`;
const link = `${appUrl}/s/${shareId}`;
return modals.openModal({
title: t("account.shares.modal.share-link"),
children: (
Expand Down
Expand Up @@ -30,7 +30,7 @@ const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
const router = useRouter();
const t = useTranslate();

const link = `${appUrl}/share/${share.id}`;
const link = `${appUrl}/s/${share.id}`;

return (
<Stack align="stretch">
Expand Down
Expand Up @@ -168,8 +168,7 @@ const CreateUploadModalBody = ({
color: theme.colors.gray[6],
})}
>
{options.appUrl}/share/
{form.values.link == "" ? "myAwesomeShare" : form.values.link}
{`${options.appUrl}/s/${form.values.link}`}
</Text>
{!options.isReverseShare && (
<>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/middleware.ts
Expand Up @@ -14,7 +14,7 @@ export const config = {
export async function middleware(request: NextRequest) {
const routes = {
unauthenticated: new Routes(["/auth/*", "/"]),
public: new Routes(["/share/*", "/upload/*"]),
public: new Routes(["/share/*", "/s/*", "/upload/*"]),
admin: new Routes(["/admin/*"]),
account: new Routes(["/account*"]),
disabled: new Routes([]),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/account/reverseShares.tsx
Expand Up @@ -159,7 +159,7 @@ const MyShares = () => {
onClick={() => {
if (window.isSecureContext) {
clipboard.copy(
`${appUrl}/share/${share.id}`
`${appUrl}/s/${share.id}`
);
toast.success(t("common.notify.copied"));
} else {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/account/shares.tsx
Expand Up @@ -132,7 +132,7 @@ const MyShares = () => {
onClick={() => {
if (window.isSecureContext) {
clipboard.copy(
`${config.get("general.appUrl")}/share/${
`${config.get("general.appUrl")}/s/${
share.id
}`
);
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/pages/s/[shareId].ts
@@ -0,0 +1,18 @@
import { GetServerSidePropsContext } from "next";

// Redirect to the share page
export function getServerSideProps(context: GetServerSidePropsContext) {
const { shareId } = context.params!;

return {
props: {},
redirect: {
permanent: false,
destination: "/share/" + shareId,
},
};
}

export default function ShareAlias() {
return null;
}

0 comments on commit 231a2e9

Please sign in to comment.