助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
[TOC] ## mattermost-server [github](https://github.com/mattermost/mattermost-server) mattermost 文档:[http://docs.mattermost.com](http://docs.mattermost.com) 开发人员文档:[https://developers.mattermost.com/integrate/](https://developers.mattermost.com/integrate/) ## 架构概述 本质上,Mattermost是一个单编译的Go二进制文件,它作为带有Javascript和Go客户端的Restful JSON Web服务器公开。请在[此处](https://api.mattermost.com/)查看Restful API文档。 它使用[config / config.json配置,](https://docs.mattermost.com/administration/config-settings.html)并提供以下内容: * **身份验证客户端**,为用户提供通过Team Edition中的电子邮件地址和密码登录Mattermost的功能。Enterprise E10增加了用户使用Active Directory或LDAP进行身份验证的能力,Enterprise E20增加了使用SAML SSO提供程序(如ADFS,OneLogin和Okta)进行身份验证的能力。 * **身份验证提供程序**,它使Mattermost服务器可以使用OAuth 2.0向其他服务(如GitLab和Zapier)进行身份验证。 * **通知服务**,该**服务**通过SMTP或推送通知服务为移动应用程序发送通知。 * **数据管理服务**,它连接到受支持的数据库和文件存储解决方案(本地,通过网络连接的存储,Amazon S3等),并管理与它们之间的数据读取和写入。 二进制文件与数据库(通常是MySQL或PostgreSQL)和文件存储进行通信。 ## 通讯协议 通信协议(HTTPS和WS)定义了用户与Mattermost服务器建立的连接类型。 **HTTPS连接**(安全超文本传输​​协议) 与Mattermost Server的HTTPS连接呈现页面并提供对核心平台功能的访问,但不包括实时交互(由WSS连接启用)。 HTTPS是安全的加密协议,强烈建议用于生产。未加密的HTTP连接可以在初始测试和配置中使用,但绝对不能在生产环境中使用。 **WSS连接**(安全WebSocket协议) 与Mattermost服务器的安全WebSocket(WSS)连接可在客户端和服务器之间进行实时更新和通知。 如果WSS连接不可用,而使用HTTPS代替,则系统似乎可以正常工作,但实时更新和通知不起作用。在这种操作模式下,更新将仅在页面刷新上显示。当连接客户端时,WSS与Mattermost服务器建立持久连接,而HTTPS具有间歇连接,仅在请求页面或文件时才连接到服务器。 ## 开发者模式 ### Incoming webhooks Mattermost支持webhooks,可轻松将外部应用程序集成到服务器中。 后台开启webhooks ![UTOOLS1593496469288.png](http://yanxuan.nosdn.127.net/36268df3f920165aced96334f62ea1a0.png) 个人集成webhooks: ![UTOOLS1593496510192.png](http://yanxuan.nosdn.127.net/a3bd53783938b18833e2b36960ce6021.png) ` ` 第一步添加webhook.第二步复制webhook连接 ![UTOOLS1593496598686.png](http://yanxuan.nosdn.127.net/d8f7573d77d9f2aaedd817310046e505.png) 使用curl请求webhook连接 ``` curl -i -X POST -H 'Content-Type: application/json' -d '{"text": "Hello, this is some text\nThis is more text. :tada:"}' http://192.168.84.250:8065/hooks/hbifon38rifsxpi6dwnis69umw # or curl -i -X POST --data-urlencode 'payload={"text": "Hello, this is some text\nThis is more text. :tada:"}' http://192.168.84.250:8065/hooks/hbifon38rifsxpi6dwnis69umw ``` 参数还可以传markdown。详情请参考:[开发人员文档](https://developers.mattermost.com/integrate/incoming-webhooks/) ``` POST http://192.168.84.250:8065/hooks/hbifon38rifsxpi6dwnis69umw Accept: */* Cache-Control: no-cache Content-Type: application/json { "channel": "off-topic", "username": "test-automation", "icon_url": "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png", "text": "#### Test results for July 27th, 2017\n@channel please review failed tests.\n\n| Component | Tests Run | Tests Failed |\n|:-----------|:-----------:|:-----------------------------------------------|\n| Server | 948 | :white_check_mark: 0 |\n| Web Client | 123 | :warning: 2 [(see details)](http://linktologs) |\n| iOS Client | 78 | :warning: 3 [(see details)](http://linktologs) |" } ``` ### OutGoing Webhooks