Skip to content

Commit 3c93d8e

Browse files
committed
fix: check connection link before searching
1 parent 1019a6e commit 3c93d8e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/controllers/NotionController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class NotionController {
3737

3838
async search(req: Request, res: Response) {
3939
try {
40+
// Check for Notion connection first
41+
const linkInfo = await this.service.getNotionLinkInfo(res.locals.owner);
42+
if (!linkInfo.isConnected) {
43+
const renewalLink = this.service.getNotionAuthorizationLink(
44+
this.service.getClientId()
45+
);
46+
return res.status(401).json({
47+
message: `Notion is not connected. Please connect your account <a href='${renewalLink}'>here</a>.`,
48+
});
49+
}
50+
51+
// Proceed with search if connected
4052
const query = req.body.query.toString() || '';
4153
const result = await this.service.search(query, getOwner(res));
4254
res.json(result);

0 commit comments

Comments
 (0)