diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..9bbf3ba --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,39 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable +# packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement +name: 'Dependency review' +on: + pull_request: + branches: [ "master" ] + +# If using a dependency submission action in this workflow this permission will need to be set to: +# +# permissions: +# contents: write +# +# https://docs.github.com/en/enterprise-cloud@latest/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api +permissions: + contents: read + # Write permissions for pull-requests are required for using the `comment-summary-in-pr` option, comment out if you aren't using this option + pull-requests: write + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v4 + # Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options. + with: + comment-summary-in-pr: always + # fail-on-severity: moderate + # deny-licenses: GPL-1.0-or-later, LGPL-2.0-or-later + # retry-on-snapshot-warnings: true diff --git a/LICENSE.txt b/LICENSE.txt index 6f2142e..5932c84 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016-2021 Jan Vales (aka. Someone ) +Copyright (c) 2024 Skorm11x Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 28028d0..be2bf4e 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,6 @@ In productive use on a 6k+ users E10 instance at https://mattermost.fsinf.at + Others may be out of scope (I cannot test E20-stuff) + Beware: I love to rebase git. :) -## If you use this or find this stuff useful, consider paying me a beer/club-mate :) -+ ``btc: bc1q9vxqzd58683ky9c2yaddaxx3wrxakggfa0dmdt`` -+ ``eth: 0x839326860d74cf61f03719c5c63db3ae5d2b443f`` -+ ``bch: qqxpm8py3flkaqdt4ehatzvx250634fuvgsgvft6z4`` -+ ``doge: DLeQq2u7gdnidaNwEtj9fYrstUaU4banNg`` -+ ``xmr: 47WwuQssrZRHLXYBRoEPmqhyG8e4PxorwWn1Xvyg6QShKAjZ83UHWJmYd9PFkpH6vPQFgNbnKvaRz1EzoQHSeeQvEGQ6ihA`` - ## Setup ``pip3 install --user --upgrade mattermost`` @@ -163,7 +156,6 @@ Ordered by https://api.mattermost.com/ + *``patch_team() #NOT_IMPLEMENTED``* + *``update_team_privacy() #NOT_IMPLEMENTED``* + *``restore_team() #NOT_IMPLEMENTED``* - + *``get_team_by_name() #NOT_IMPLEMENTED``* + *``search_teams() #NOT_IMPLEMENTED``* + *``exists_team() #NOT_IMPLEMENTED``* + *``get_teams_for_user() #NOT_IMPLEMENTED``* diff --git a/mattermost/__init__.py b/mattermost/__init__.py index 8f8bf5d..0fbd29d 100644 --- a/mattermost/__init__.py +++ b/mattermost/__init__.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 """ Someone's Mattermost API v4 bindings. Copyright (c) 2016-2021 by Someone (aka. Jan Vales ) + Forked 2024 skorm11x. published under MIT-License """ @@ -204,8 +204,19 @@ def logout(self, **kwargs): ################################################ #+ **USERS** - - #def create_user() #NOT_IMPLEMENTED + #merged this: https://github.com/someone-somenet-org/mattermost-python-api/pull/2 + # credit for @haalcala 4SEP2022 + def create_user(self, props=None, **kwargs): + """ + Create user. + Args: + props (dict, optional): fields for creating the user (See https://api.mattermost.com/#tag/users/operation/CreateUser). + Returns: + dict: User. + Raises: + ApiException: Passed on from lower layers. + """ + return self._post("/v4/users", data=props, **kwargs) @@ -555,7 +566,21 @@ def get_team(self, team_id, **kwargs): #def patch_team() #NOT_IMPLEMENTED #def update_team_privacy() #NOT_IMPLEMENTED #def restore_team() #NOT_IMPLEMENTED - #def get_team_by_name() #NOT_IMPLEMENTED + def get_team_by_name(self, team_name, **kwargs): + """ + Get a team on the system. + + Args: + team_name (string): team_name. + + Returns: + dict: Team. + + Raises: + ApiException: Passed on from lower layers. + """ + + return self._get("/v4/teams/name/" + team_name, **kwargs) #def search_teams() #NOT_IMPLEMENTED #def exists_team() #NOT_IMPLEMENTED #def get_teams_for_user() #NOT_IMPLEMENTED @@ -913,6 +938,7 @@ def search_channel(self, team_id, term, **kwargs): def get_channel_by_name(self, team_id, channel_name, include_deleted=None, **kwargs): + # TODO FIX# this does not find channels by display names! """ Gets channel from the provided team id and channel name strings. @@ -1071,8 +1097,9 @@ def get_channels_for_user(self, user_id, team_id, **kwargs): ################################################ #+ **POSTS** - - def create_post(self, channel_id, message, props=None, filepaths=None, root_id=None, **kwargs): + # merged this: https://github.com/someone-somenet-org/mattermost-python-api/pull/3/commits/e71961e62460f0f1bafa15dbf79896c4078a7c80 + # credit 21JUL2023 @serbeh + def create_post(self, channel_id, message, props=None, filepaths=None, root_id=None, metadata=None, **kwargs): """ Create a new post in a channel. To create the post as a comment on another post, provide root_id. @@ -1082,6 +1109,7 @@ def create_post(self, channel_id, message, props=None, filepaths=None, root_id=N props (string, optional): see MM-API docs. filepaths (list, optional): Paths to upload files from and attach to post. root_id (string, optional): see MM-API docs. + metadata (dict, optional): Priority metadata. see MM-API docs. Returns: dict: created Post. @@ -1098,12 +1126,12 @@ def create_post(self, channel_id, message, props=None, filepaths=None, root_id=N "channel_id": channel_id, "message": message, **({"props": props} if props else {"props": {"from_webhook":"true"}}), + **({"metadata": metadata} if metadata else {"metadata": {}}), "root_id":root_id, "file_ids": file_ids, }, **kwargs) - def create_ephemeral_post(self, channel_id, message, user_id, **kwargs): """ Create a new ephemeral post in a channel. diff --git a/mattermost/stdin2channel.py b/mattermost/stdin2channel.py index e436030..119ccac 100755 --- a/mattermost/stdin2channel.py +++ b/mattermost/stdin2channel.py @@ -1,9 +1,8 @@ -#!/usr/bin/env python3 """ Someone's Mattermost API v4 bindings. Copyright (c) 2016-2021 by Someone (aka. Jan Vales ) published under MIT-License - + Forked 2024 skorm11x. post stdin to a channel. """ diff --git a/mattermost/version.py b/mattermost/version.py index 68d830f..bda7a94 100755 --- a/mattermost/version.py +++ b/mattermost/version.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python3 """ Someone's Mattermost API v4 bindings. - Copyright (c) 2016-2021 by Someone (aka. Jan Vales ) + Copyright (c) 2024 by skorm11x + Forked 2024 skorm11x. published under MIT-License """ # Set this package's version. -__version__ = "6.5.0" +__version__ = "0.0.1" diff --git a/mattermost/ws.py b/mattermost/ws.py index 5390c61..ca6e3b9 100644 --- a/mattermost/ws.py +++ b/mattermost/ws.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 """ Someone's Mattermost API v4 bindings. Copyright (c) 2016-2021 by Someone (aka. Jan Vales ) + Forked 2024 skorm11x. published under MIT-License """