Search in sources :

Example 6 with Webhook

use of com.erudika.para.core.Webhook in project scoold by Erudika.

the class AdminController method deleteWebhook.

@PostMapping("/delete-webhook")
public String deleteWebhook(@RequestParam String id, HttpServletRequest req, HttpServletResponse res) {
    Profile authUser = utils.getAuthUser(req);
    if (!StringUtils.isBlank(id) && utils.isAdmin(authUser) && utils.isWebhooksEnabled()) {
        Webhook webhook = new Webhook();
        webhook.setId(id);
        pc.delete(webhook);
    }
    if (utils.isAjaxRequest(req)) {
        res.setStatus(200);
        return "base";
    } else {
        return "redirect:" + ADMINLINK;
    }
}
Also used : Webhook(com.erudika.para.core.Webhook) Profile(com.erudika.scoold.core.Profile) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 7 with Webhook

use of com.erudika.para.core.Webhook in project scoold by Erudika.

the class ApiController method deleteWebhook.

@DeleteMapping("/webhooks/{id}")
public void deleteWebhook(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
    if (!utils.isWebhooksEnabled()) {
        res.setStatus(HttpStatus.FORBIDDEN.value());
    }
    Webhook webhook = pc.read(id);
    if (webhook == null) {
        res.setStatus(HttpStatus.NOT_FOUND.value());
        return;
    }
    pc.delete(webhook);
}
Also used : Webhook(com.erudika.para.core.Webhook) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Aggregations

Webhook (com.erudika.para.core.Webhook)7 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 Profile (com.erudika.scoold.core.Profile)3 ParaObject (com.erudika.para.core.ParaObject)2 Locked (com.erudika.para.core.annotations.Locked)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1 PatchMapping (org.springframework.web.bind.annotation.PatchMapping)1