Skip to content

Commit

Permalink
fix: check connection link before searching
Browse files Browse the repository at this point in the history
  • Loading branch information
aalemayhu committed Jan 7, 2025
1 parent 12805a4 commit bb5d0c7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/controllers/NotionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class NotionController {

async search(req: Request, res: Response) {
try {
// Check for Notion connection first
const linkInfo = await this.service.getNotionLinkInfo(res.locals.owner);
if (!linkInfo.isConnected) {
const renewalLink = this.service.getNotionAuthorizationLink(
this.service.getClientId()
);
return res.status(401).json({
message: `Notion is not connected. Please connect your account <a href='${renewalLink}'>here</a>.`,
});
}

// Proceed with search if connected
const query = req.body.query.toString() || '';
const result = await this.service.search(query, getOwner(res));
res.json(result);
Expand Down

0 comments on commit bb5d0c7

Please sign in to comment.