def post(self, alert_id): req = request.get_json(True) alert = models.Alert.get_by_id_and_org(alert_id, self.current_org) require_access(alert.groups, self.current_user, view_only) kwargs = {'alert': alert, 'user': self.current_user} if 'destination_id' in req: destination = models.NotificationDestination.get_by_id_and_org( req['destination_id'], self.current_org) kwargs['destination'] = destination subscription = models.AlertSubscription(**kwargs) models.db.session.add(subscription) models.db.session.commit() self.record_event({ 'action': 'subscribe', 'timestamp': int(time.time()), 'object_id': alert_id, 'object_type': 'alert', 'destination': req.get('destination_id') }) d = subscription.to_dict() return d
def post(self, alert_id): req = request.get_json(True) alert = models.Alert.get_by_id_and_org(alert_id, self.current_org) require_access(alert, self.current_user, view_only) kwargs = {"alert": alert, "user": self.current_user} if "destination_id" in req: destination = models.NotificationDestination.get_by_id_and_org( req["destination_id"], self.current_org) kwargs["destination"] = destination subscription = models.AlertSubscription(**kwargs) models.db.session.add(subscription) models.db.session.commit() self.record_event({ "action": "subscribe", "object_id": alert_id, "object_type": "alert", "destination": req.get("destination_id"), }) d = subscription.to_dict() return d
def post(self, alert_id): req = request.get_json(True) alert = models.Alert.get_by_id_and_org(alert_id, self.current_org) require_access(alert, self.current_user, view_only) kwargs = {'alert': alert, 'user': self.current_user} if 'destination_id' in req: destination = models.NotificationDestination.get_by_id_and_org( req['destination_id'], self.current_org) kwargs['destination'] = destination subscription = models.AlertSubscription(**kwargs) models.db.session.add(subscription) models.db.session.commit() d = subscription.to_dict() return d