From 09721ad4a47f6d54d200f202ae88ad86e78b1f88 Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Fri, 9 Dec 2022 13:14:07 +0000 Subject: [PATCH] Remove necessary parameter --- custom_components/o365/calendar.py | 14 ++++++++------ custom_components/o365/classes/taskssensor.py | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/custom_components/o365/calendar.py b/custom_components/o365/calendar.py index 3e8d27e..2c902c1 100644 --- a/custom_components/o365/calendar.py +++ b/custom_components/o365/calendar.py @@ -272,7 +272,7 @@ def create_calendar_event( categories = [] if attendees is None: attendees = [] - if not self._validate_permissions("create", self._config): + if not self._validate_permissions("create"): return calendar = self.data.calendar @@ -313,7 +313,7 @@ def modify_calendar_event( if attendees is None: attendees = [] - if not self._validate_permissions("modify", self._config): + if not self._validate_permissions("modify"): return if self.data.group_calendar: @@ -338,7 +338,7 @@ def modify_calendar_event( def remove_calendar_event(self, event_id): """Remove the event.""" - if not self._validate_permissions("delete", self._config): + if not self._validate_permissions("delete"): return if self.data.group_calendar: @@ -352,7 +352,7 @@ def respond_calendar_event( self, event_id, response, send_response=True, message=None ): """Respond to calendar event.""" - if not self._validate_permissions("respond to", self._config): + if not self._validate_permissions("respond to"): return if self.data.group_calendar: @@ -376,10 +376,12 @@ def _get_event_from_calendar(self, event_id): calendar = self.data.calendar return calendar.get_event(event_id) - def _validate_permissions(self, error_message, config): + def _validate_permissions(self, error_message): permissions = get_permissions( self.hass, - filename=build_token_filename(config, config.get(CONF_CONFIG_TYPE)), + filename=build_token_filename( + self._config, self._config.get(CONF_CONFIG_TYPE) + ), ) if not validate_minimum_permission(PERM_MINIMUM_CALENDAR_WRITE, permissions): raise vol.Invalid( diff --git a/custom_components/o365/classes/taskssensor.py b/custom_components/o365/classes/taskssensor.py index c36d904..126645f 100644 --- a/custom_components/o365/classes/taskssensor.py +++ b/custom_components/o365/classes/taskssensor.py @@ -62,7 +62,7 @@ def extra_state_attributes(self): def new_task(self, subject, description=None, due=None, reminder=None): """Create a new task for this task list.""" - if not self._validate_permissions(self._config): + if not self._validate_permissions(): return # sourcery skip: raise-from-previous-error @@ -85,10 +85,12 @@ def new_task(self, subject, description=None, due=None, reminder=None): new_task.save() return True - def _validate_permissions(self, config): + def _validate_permissions(self): permissions = get_permissions( self.hass, - filename=build_token_filename(config, config.get(CONF_CONFIG_TYPE)), + filename=build_token_filename( + self._config, self._config.get(CONF_CONFIG_TYPE) + ), ) if not validate_minimum_permission(PERM_MINIMUM_TASKS_WRITE, permissions): raise vol.Invalid(