Skip to content

Commit

Permalink
add community posting, closes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
kualta committed Jul 4, 2024
1 parent f88d12e commit 354bfa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/api/posts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export async function POST(req: NextRequest) {
try {
const { searchParams } = req.nextUrl;
const replyingTo = searchParams.get("replyingTo") || undefined;

const data = await parseRequestBody(req);

const { client, isAuthenticated, handle } = await getLensClient();

validateAuthentication(isAuthenticated);
Expand Down
10 changes: 8 additions & 2 deletions src/components/post/PostWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Form, FormControl, FormField, FormItem } from "@/src/components/ui/form
import { zodResolver } from "@hookform/resolvers/zod";
import { textOnly } from "@lens-protocol/metadata";
import { LoaderIcon, SendHorizontalIcon } from "lucide-react";
import { usePathname } from "next/navigation";
import { type KeyboardEvent, useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
Expand All @@ -19,6 +20,9 @@ export default function PostWizard({ user, replyingTo }: { user?: User; replying
const [isPosting, setPosting] = useState(false);
const placeholderText = replyingTo ? "write your reply..." : "write a new post...";

const pathname = usePathname().split("/");
const community = pathname[1] === "c" ? pathname[2] : "global";

const FormSchema = z.object({
content: z.string().max(3000, {
message: "Post must not be longer than 3000 characters.",
Expand All @@ -34,6 +38,7 @@ export default function PostWizard({ user, replyingTo }: { user?: User; replying

const metadata = textOnly({
content: data.content,
tags: [community],
appId: "Ping",
});

Expand Down Expand Up @@ -86,8 +91,9 @@ export default function PostWizard({ user, replyingTo }: { user?: User; replying
>
{user && (
<div className="w-10 h-10">
<UserAvatar user={user} link={true} card={false} />
</div>)}
<UserAvatar user={user} link={true} card={false} />
</div>
)}
<FormField
control={form.control}
name="content"
Expand Down

0 comments on commit 354bfa9

Please sign in to comment.