Pour que les scripts fonctionnent bien, il est necesaire d'utiliser le compte admin de l'instance mattermost. (Les identifiants de Picasoft se trouvent dans la section privée du wiki).
### Utilisation
* Depuis n'importe quel ordi sous linux, télecharger ce dossier, extraire et ouvrir un terminal dessus.
* Le script garde dans le fichier teams_anciennes.txt les détails des teams où le dernier message a été envoyé il y a plus de 1 an (id, display_name, email de l'admin de la team et la date du dernier message sur cette team)
* Si vous voulez modifier cette durée, il suffit de modifier cette ligne: `age_limite=31536000` (au début de mattermost_api_liste_teams_anciennes.sh). Il faut mettre une durée en secondes.
### Problèmes actuels
* Lorsqu'on génère un token, la commande qu'on a tappé (et donc le mot de passe du compte admin) reste dans l'historique! (~/.bash_history)
### Contribution
Toute contribution est bienvenue! N'hésitez pas à ouvrir une pull request ou à m'envoyer un mail sur amaldona@etu.utc.fr
### Licence
The MIT License
Copyright (c) 2017 Andrés Maldonado
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Ce *repository* héberge plusieurs scripts qui facilitent l'administration de Mattermost pour Picasoft.
-`team_inactives` permet de détecter les équipes inactives
-`disable_notifications` permet de désactiver les notifications mail d'une adresse mail donnée (utile pour de vieux comptes avec des adresses etu)
This script simply disable email notifications for a user and send a private message. It is useful when people have a wrong or deleted email address associated to their account (eg. old UTC student email).
This script need some requirements that you can install with `pip install requirements.txt`.
The script need access to an admin account on the Mattermost server. To provide authentication information there is 2 way :
- envrionment variables : `MM_URL` (eg. `https://team.picasoft.net`), `MM_USER` and `MM_PASSWORD`
- CLI arguments : `--mm-url`, `--mm-user` and `--mm-password`
Also, there is a required CLI argument : `--email` which is the mail of the user that need to have notifications disabled.
NOTIF_MESSAGE="""Salut ! Ceci est un message "automatique" de Picasoft :).
On a constaté des erreurs d'envois des mails de notifications de Mattermost vers ton adresse mail `[[EMAIL]]`. Un robot a donc désactivé les notifications par mails de ton compte Mattermost.
Cela peut venir du fait que ton adresse n'existe plus, ou encore d'un problème venant de ton serveur mail ou de celui de Picasoft. Si tu penses que l'on fait erreur et/ou pour avoir plus d'informations, n'hésite pas à nous contacter sur notre équipe Mattermost `Picasoft` ou par mail à `contact@picasoft.net`."""
defmattermost_connect(args):
"""
Instanciate a Mattermost connector.
:param args: CLI arguments
:return mat_api: A Mattermost APi connector
"""
# Extract Mattermost server informations
ifargs.mm_urlisnotNone:
mm_url=args.mm_url
elifos.getenv('MM_URL')isnotNone:
mm_url=os.getenv('MM_URL')
else:
print('You need to specify --mm-url or MM_URL environment variable !')
sys.exit(1)
ifargs.mm_userisnotNone:
mm_user=args.mm_user
elifos.getenv('MM_USER')isnotNone:
mm_user=os.getenv('MM_USER')
else:
print('You need to specify --mm-user or MM_USER environment variable !')
sys.exit(1)
ifargs.mm_passwordisnotNone:
mm_password=args.mm_password
elifos.getenv('MM_PASSWORD')isnotNone:
mm_password=os.getenv('MM_PASSWORD')
else:
print('You need to specify --mm-password or MM_PASSWORD environment variable !')
sys.exit(1)
# Parse Mattermost URL
o=urlparse(mm_url)
ifo.portisNone:
ifo.scheme=='https':
mm_port=443
elifo.scheme=='http':
mm_port=80
else:
print('Impossible to get Mattermost server port for '+mm_url)
Pour que les scripts fonctionnent bien, il est necesaire d'utiliser le compte admin de l'instance mattermost. (Les identifiants de Picasoft se trouvent dans la section privée du wiki).
### Utilisation
* Depuis n'importe quel ordi sous linux, télecharger ce dossier, extraire et ouvrir un terminal dessus.
* Le script garde dans le fichier teams_anciennes.txt les détails des teams où le dernier message a été envoyé il y a plus de 1 an (id, display_name, email de l'admin de la team et la date du dernier message sur cette team)
* Si vous voulez modifier cette durée, il suffit de modifier cette ligne: `age_limite=31536000` (au début de mattermost_api_liste_teams_anciennes.sh). Il faut mettre une durée en secondes.
### Problèmes actuels
* Lorsqu'on génère un token, la commande qu'on a tappé (et donc le mot de passe du compte admin) reste dans l'historique! (~/.bash_history)
### Contribution
Toute contribution est bienvenue! N'hésitez pas à ouvrir une pull request ou à m'envoyer un mail sur amaldona@etu.utc.fr
### Licence
The MIT License
Copyright (c) 2017 Andrés Maldonado
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.