Skip to content

Commit b75e31c

Browse files
committed
fix: wrong get flow
1 parent 9cd23ee commit b75e31c

File tree

11 files changed

+765
-46
lines changed

11 files changed

+765
-46
lines changed

server/src/controllers/channels.controller.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,18 @@ export class ChannelController {
7878
res.status(StatusCodes.OK).json({ data })
7979
},
8080
)
81+
82+
public getChannelForTest = catchAsync(async (req: RequestWithUser, res) => {
83+
const data = await this.channelService.getChannelForTest(req.user.id)
84+
res.status(StatusCodes.OK).json({ data })
85+
})
86+
87+
public updateChannelForTest = catchAsync(
88+
async (req: RequestWithUser, res) => {
89+
await this.channelService.updateChannelForTest(req.user.id, req.body)
90+
res.status(StatusCodes.OK).json({
91+
message: this.localeService.i18n().CHANNEL.UPDATE_SUCCESS(),
92+
})
93+
},
94+
)
8195
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CREATE TABLE IF NOT EXISTS "conversations" (
2+
"user_id" varchar NOT NULL,
3+
"created_at" timestamp DEFAULT now(),
4+
"updated_at" timestamp DEFAULT now(),
5+
CONSTRAINT "user_id" UNIQUE("user_id")
6+
);
7+
--> statement-breakpoint
8+
CREATE TABLE IF NOT EXISTS "messages" (
9+
"id" varchar(36) PRIMARY KEY NOT NULL,
10+
"conversation_id" varchar(36) NOT NULL,
11+
"created_at" timestamp DEFAULT now(),
12+
"from" text NOT NULL,
13+
"to" text NOT NULL,
14+
"type" text DEFAULT 'text' NOT NULL,
15+
"data" json DEFAULT '{"text":""}'::json
16+
);
17+
--> statement-breakpoint
18+
DO $$ BEGIN
19+
ALTER TABLE "messages" ADD CONSTRAINT "messages_conversation_id_conversations_user_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "conversations"("user_id") ON DELETE cascade ON UPDATE no action;
20+
EXCEPTION
21+
WHEN duplicate_object THEN null;
22+
END $$;

0 commit comments

Comments
 (0)