From 9251b5406ff0f099736f566a5d7f973c1528044d Mon Sep 17 00:00:00 2001 From: Christopher Kosik <37384678+skorm11x@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:22:11 -0700 Subject: [PATCH 1/6] Update README.md removed fork user fund info. --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 28028d0..277cb9c 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`` From 75c38f2d5d222527fda267645c88f5c53e3bc53e Mon Sep 17 00:00:00 2001 From: skorm11x Date: Sat, 24 Feb 2024 14:43:43 -0700 Subject: [PATCH 2/6] Updated LICENSE.txt, copyright header for files, merged old pull requests from original repo: https://github.com/someone-somenet-org/mattermost-python-api --- LICENSE.txt | 2 +- mattermost/__init__.py | 25 +++++++++++++++++++------ mattermost/stdin2channel.py | 3 +-- mattermost/version.py | 6 +++--- mattermost/ws.py | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) 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/mattermost/__init__.py b/mattermost/__init__.py index 8f8bf5d..435d07f 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) @@ -1071,8 +1082,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 +1094,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 +1111,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 """ From c81f48d2b8cfbff95d300e872e1d7c753bb6974a Mon Sep 17 00:00:00 2001 From: skorm11x Date: Sat, 24 Feb 2024 15:19:55 -0700 Subject: [PATCH 3/6] Added get_team_by_name() --- mattermost/__init__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mattermost/__init__.py b/mattermost/__init__.py index 435d07f..a7c2dc1 100644 --- a/mattermost/__init__.py +++ b/mattermost/__init__.py @@ -566,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 From 92f6fe4b630505496382dcdb0936dfbdacb5a471 Mon Sep 17 00:00:00 2001 From: skorm11x Date: Sat, 24 Feb 2024 16:23:54 -0700 Subject: [PATCH 4/6] Added todo fixing finding channels by display name. --- mattermost/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mattermost/__init__.py b/mattermost/__init__.py index a7c2dc1..0fbd29d 100644 --- a/mattermost/__init__.py +++ b/mattermost/__init__.py @@ -938,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. From 1ac0e327280fef06e1359970d7ecbdbf9c2a74d5 Mon Sep 17 00:00:00 2001 From: Christopher Kosik <37384678+skorm11x@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:19:49 -0700 Subject: [PATCH 5/6] Update README.md to reflect implemented get_team_by_name --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 277cb9c..be2bf4e 100644 --- a/README.md +++ b/README.md @@ -156,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``* From e3b26b42be4b5c0b70a290dadb15cc56ea70ab95 Mon Sep 17 00:00:00 2001 From: Christopher Kosik <37384678+skorm11x@users.noreply.github.com> Date: Mon, 26 Feb 2024 07:29:29 -0700 Subject: [PATCH 6/6] Create dependency-review.yml --- .github/workflows/dependency-review.yml | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/dependency-review.yml 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