403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/mattermost.py
"""
Library for interacting with Mattermost Incoming Webhooks
:configuration: This module can be used by specifying the name of a
    configuration profile in the minion config, minion pillar, or master
    config.
    For example:
    .. code-block:: yaml

        mattermost:
          hook: 3tdgo8restnxiykdx88wqtxryr
          api_url: https://example.com
"""

import http.client
import logging
import urllib.parse

import salt.utils.http
from salt.version import __version__

log = logging.getLogger(__name__)


def query(hook=None, api_url=None, data=None):
    """
    Mattermost object method function to construct and execute on the API URL.
    :param api_url:     The Mattermost API URL
    :param hook:        The Mattermost hook.
    :param data:        The data to be sent for POST method.
    :return:            The json response from the API call or False.
    """
    method = "POST"

    ret = {"message": "", "res": True}

    base_url = urllib.parse.urljoin(api_url, "/hooks/")
    url = urllib.parse.urljoin(base_url, str(hook))

    result = salt.utils.http.query(url, method, data=data, decode=True, status=True)

    if result.get("status", None) == http.client.OK:
        ret["message"] = f"Message posted {data} correctly"
        return ret
    elif result.get("status", None) == http.client.NO_CONTENT:
        return True
    else:
        log.debug(url)
        log.debug(data)
        log.debug(result)
        if "dict" in result:
            _result = result["dict"]
            if "error" in _result:
                ret["message"] = result["error"]
                ret["res"] = False
                return ret
            ret["message"] = "Message not posted"
        else:
            ret["message"] = "invalid_auth"
            ret["res"] = False
    return ret

Youez - 2016 - github.com/yon3zu
LinuXploit