Fixing api points not returning (#2419)
Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
		
							parent
							
								
									06df6c9e91
								
							
						
					
					
						commit
						fefc314d35
					
				
					 4 changed files with 8 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -8,8 +8,7 @@ const scopes = ["commands", "users:read", "users:read.email"];
 | 
			
		|||
 | 
			
		||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
 | 
			
		||||
  if (!req.session?.user?.id) {
 | 
			
		||||
    res.status(401).json({ message: "You must be logged in to do this" });
 | 
			
		||||
    return;
 | 
			
		||||
    return res.status(401).json({ message: "You must be logged in to do this" });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (req.method === "GET") {
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +30,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
 | 
			
		|||
    const url = `https://slack.com/oauth/v2/authorize?${query}&user_`;
 | 
			
		||||
    // const url =
 | 
			
		||||
    //   "https://slack.com/oauth/v2/authorize?client_id=3194129032064.3178385871204&scope=chat:write,commands&user_scope=";
 | 
			
		||||
    res.status(200).json({ url });
 | 
			
		||||
    return res.status(200).json({ url });
 | 
			
		||||
  }
 | 
			
		||||
  res.status(404).json({ error: "Not Found" });
 | 
			
		||||
  return res.status(404).json({ error: "Not Found" });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,14 +8,12 @@ const client_secret = process.env.SLACK_CLIENT_SECRET;
 | 
			
		|||
 | 
			
		||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
 | 
			
		||||
  if (!req.session?.user?.id) {
 | 
			
		||||
    res.status(401).json({ message: "You must be logged in to do this" });
 | 
			
		||||
    return;
 | 
			
		||||
    return res.status(401).json({ message: "You must be logged in to do this" });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (req.method === "GET") {
 | 
			
		||||
    // Get user
 | 
			
		||||
    const { code } = req.query;
 | 
			
		||||
    console.log(req.query);
 | 
			
		||||
 | 
			
		||||
    if (!code) {
 | 
			
		||||
      res.redirect("/apps/installed"); // Redirect to where the user was if they cancel the signup or if the oauth fails
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +44,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
 | 
			
		|||
        },
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
    res.redirect("/apps/installed");
 | 
			
		||||
    return res.redirect("/apps/installed");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,5 +24,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
 | 
			
		|||
        return res.status(404).json({ message: `Command not found` });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  res.status(400).json({ message: "Invalid request" });
 | 
			
		||||
  return res.status(400).json({ message: "Invalid request" });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,8 +16,8 @@ export default async function interactiveHandler(req: NextApiRequest, res: NextA
 | 
			
		|||
      case InteractionEvents.CREATE_EVENT:
 | 
			
		||||
        return await createEvent(req, res);
 | 
			
		||||
      default:
 | 
			
		||||
        res.status(200).end(); // Techincally an invalid request but we don't want to return an throw an error to slack - 200 just does nothing
 | 
			
		||||
        return res.status(200).end(); // Techincally an invalid request but we don't want to return an throw an error to slack - 200 just does nothing
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  res.status(200).end(); // Send 200 if we dont have a case for the action_id
 | 
			
		||||
  return res.status(200).end(); // Send 200 if we dont have a case for the action_id
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue