Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ has_duplicate
will use ``MEDIA_SETTINGS_KEY`` to lookup the most important piece of
information in the settings.

get_relevant_address
Used by ``send``. You should only need to override this if the key in
MEDIA_SETTINGS_KEY is insuffcient to look up the actual configuration of the
destinations of the type set by MEDIA_SLUG.

``raise_if_not_deletable`` should check if a given destination can be deleted.
This is used in case some destinations are managed by an outside source and
should not be able to be deleted by a user. If that is the case a
Expand Down
10 changes: 1 addition & 9 deletions src/argus/notificationprofile/media/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,8 @@ def get_label(cls, destination: DestinationConfig) -> str:
def get_relevant_address(cls, destination: DestinationConfig) -> Any:
"""
Returns the "address" to send the message to

The type of the address depends on the medium, it must be something
``cls.send()`` understands.
"""
raise NotImplementedError
return destination.settings[cls.MEDIA_SETTINGS_KEY]

@classmethod
def get_relevant_destinations(cls, destinations: Iterable[DestinationConfig]) -> set[DestinationConfig]:
Expand Down Expand Up @@ -242,11 +239,6 @@ def validate(cls, instance: RequestDestinationConfigSerializer, apprise_dict: di

return form.cleaned_data

@classmethod
def get_relevant_address(cls, destination: DestinationConfig) -> Any:
"""Returns the Apprise destination url the message should be sent to"""
return destination.settings["destination_url"]

@staticmethod
def create_message_context(event: Event):
"""Creates the subject and message for the Apprise notification"""
Expand Down
7 changes: 1 addition & 6 deletions src/argus/notificationprofile/media/email.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

from django import forms
from django.conf import settings
Expand Down Expand Up @@ -99,11 +99,6 @@ def validate(self, instance: RequestDestinationConfigSerializer, email_dict: dic

return form.cleaned_data

@classmethod
def get_relevant_address(cls, destination: DestinationConfig) -> Any:
"""Returns an email address the message should be sent to"""
return destination.settings["email_address"]

@staticmethod
def create_message_context(event: Event):
"""Creates the subject, message and html message for the email"""
Expand Down
7 changes: 1 addition & 6 deletions src/argus/notificationprofile/media/sms_as_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

from django import forms
from django.conf import settings
Expand Down Expand Up @@ -73,11 +73,6 @@ def validate(cls, instance: RequestDestinationConfigSerializer, sms_dict: dict,

return form.cleaned_data

@classmethod
def get_relevant_address(cls, destination: DestinationConfig) -> Any:
"Get a single phone number from the destination, as a string"
return destination.settings["phone_number"]

@classmethod
def send(cls, event: Event, destinations: Iterable[DestinationConfig], **_) -> bool:
"""
Expand Down
Loading