|
| 1 | +class OpenCTIApiNotification: |
| 2 | + """OpenCTIApiJob""" |
| 3 | + |
| 4 | + def __init__(self, api): |
| 5 | + self.api = api |
| 6 | + |
| 7 | + def delete(self, **kwargs): |
| 8 | + notification_id = kwargs.get("id", None) |
| 9 | + self.api.app_logger.info( |
| 10 | + "Deleting notifcation", {"notification_id": notification_id} |
| 11 | + ) |
| 12 | + query = """ |
| 13 | + mutation notificationDelete($id: ID!) { |
| 14 | + notificationDelete(id: $id) |
| 15 | + } |
| 16 | + """ |
| 17 | + self.api.query(query, {"id": notification_id}) |
| 18 | + |
| 19 | + def update_field(self, **kwargs): |
| 20 | + notification_id = kwargs.get("id", None) |
| 21 | + input = kwargs.get("input", None) |
| 22 | + for input_value in input: |
| 23 | + if input_value["key"] == "is_read": |
| 24 | + is_read_value = bool(input_value["value"][0]) |
| 25 | + self.mark_as_read(notification_id, is_read_value) |
| 26 | + |
| 27 | + def mark_as_read(self, notification_id: str, read: bool): |
| 28 | + self.api.app_logger.info( |
| 29 | + "Marking notifcation as read", |
| 30 | + {"notification_id": notification_id, "read": read}, |
| 31 | + ) |
| 32 | + query = """ |
| 33 | + mutation notificationMarkRead($id: ID!, $read: Boolean!) { |
| 34 | + notificationMarkRead(id: $id, read: $read) { |
| 35 | + id |
| 36 | + } |
| 37 | + } |
| 38 | + """ |
| 39 | + self.api.query(query, {"id": notification_id, "read": read}) |
0 commit comments