Skip to content

Commit

Permalink
Remove necessary parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Dec 9, 2022
1 parent acd9ab2 commit 09721ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions custom_components/o365/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions custom_components/o365/classes/taskssensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 09721ad

Please sign in to comment.