Skip to content

Commit 07f8828

Browse files
committed
MatchingStatusSchemaを追加
1 parent 7b689da commit 07f8828

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

common/zod/schemas.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@ export const SendMessageSchema = z.object({
123123
content: z.string().min(1, { message: "Content must not be empty." }),
124124
});
125125

126+
export const MatchingStatusSchema = z.union([
127+
z.literal("myRequest"),
128+
z.literal("otherRequest"),
129+
z.literal("matched"),
130+
]);
131+
126132
export const DMOverviewSchema = z.object({
127133
isDM: z.literal(true),
128-
isFriend: z.boolean(),
134+
matchingStatus: MatchingStatusSchema,
129135
friendId: UserIDSchema,
130136
name: NameSchema,
131137
thumbnail: z.string(),
@@ -154,7 +160,7 @@ export const DMRoomSchema = z.object({
154160
export const PersonalizedDMRoomSchema = z.object({
155161
name: NameSchema,
156162
thumbnail: z.string(),
157-
isFriend: z.boolean(),
163+
matchingStatus: MatchingStatusSchema,
158164
});
159165

160166
export const SharedRoomSchema = z.object({

server/src/functions/chat.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ export async function getDM(
7777
const personalized: PersonalizedDMRoom & DMRoom = {
7878
name: friendData.value.name,
7979
thumbnail: friendData.value.pictureUrl,
80-
isFriend: rel.value.status === "MATCHED",
80+
matchingStatus:
81+
rel.value.status === "MATCHED"
82+
? "matched"
83+
: rel.value.status === "PENDING"
84+
? "myRequest"
85+
: "otherRequest", //Fix Me: これだとREJECTEDの時に、matchingStatus = otherRequest になってしまう。本当はちゃんと判別しないといけない。呼び出し口でこれがちゃんと使われてないので、無視している。
8186
...room.value,
8287
};
8388

server/src/router/chat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ router.get("/overview", async (req, res) => {
2323
res.status(result.code).send(result.body);
2424
});
2525

26-
// send DM to userid.
26+
// send DM to userId.
2727
router.post("/dm/to/:userid", async (req, res) => {
2828
const user = await safeGetUserId(req);
2929
if (!user.ok) return res.status(401).send("auth error");
3030
const friend = safeParseInt(req.params.userid);
31-
if (!friend.ok) return res.status(400).send("bad param encoding: `userid`");
31+
if (!friend.ok) return res.status(400).send("bad param encoding: `userId`");
3232

3333
const send = SendMessageSchema.safeParse(req.body);
3434
if (!send.success) {
@@ -42,14 +42,14 @@ router.post("/dm/to/:userid", async (req, res) => {
4242
res.status(result.code).send(result.body);
4343
});
4444

45-
// GET a DM Room with userid, CREATE one if not found.
45+
// GET a DM Room with userId, CREATE one if not found.
4646
router.get("/dm/with/:userid", async (req, res) => {
4747
const user = await safeGetUserId(req);
4848
if (!user.ok) return res.status(401).send("auth error");
4949

5050
const friend = safeParseInt(req.params.userid);
5151
if (!friend.ok)
52-
return res.status(400).send("invalid param `userid` formatting");
52+
return res.status(400).send("invalid param `userId` formatting");
5353

5454
const result = await core.getDM(user.value, friend.value);
5555

web/components/human/humanListItem.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type HumanListItemProps = {
77
pictureUrl: string;
88
lastMessage?: string;
99
rollUpName?: boolean; // is currently only intended to be used in Chat
10+
statusMessage?: string;
1011
onDelete?: (id: number) => void;
1112
onOpen?: (user: { id: number; name: string; pictureUrl: string }) => void;
1213
onAccept?: (id: number) => void;
@@ -23,6 +24,7 @@ export function HumanListItem(props: HumanListItemProps) {
2324
pictureUrl,
2425
rollUpName,
2526
lastMessage,
27+
statusMessage,
2628
onDelete,
2729
onOpen,
2830
onAccept,
@@ -61,6 +63,9 @@ export function HumanListItem(props: HumanListItemProps) {
6163
{lastMessage}
6264
</span>
6365
)}
66+
{statusMessage && (
67+
<span className="text-blue-500 text-sm">{statusMessage}</span>
68+
)}
6469
</div>
6570
</button>
6671
<div className="flex items-center space-x-2">

0 commit comments

Comments
 (0)