* Update system_user_detail to enable editing of User Attributes
- This adds a `updateUserCustomProfileAttributesValues` method to client4 to allow updating attributes for a given userID, as a match to getUserCustomProfilesAttributesValues
- Fixed issue in saveCustomProfileAttributes where it used the version that did not take the passed in userId
* Fixes for tests
* Update saveCustomProfileAttribute mock in users.test.ts
The `saveCustomProfileAttribute` test was still using the old getCustomProfileAttributeValuesRoute instead of the same route that `getCustomProfileAttributeValues` uses.
* Adding e2e tests for editing User attributes (custom and system) in System Console
* Fix testing issue with selector for 'Authentication Method'
* workflows/server-ci-report.yml: security fixes by validating inputs (#33892)
* [MM-61899] Properly restrict users who previously shared a team from DMs/GMs when they no longer share a team. (#30094)
* [MM-61899] Properly restrict users who previously shared a team from DMs/GMs when they no longer share a team.
* Fix checks
* Fix test
* Fix i18n
* Added E2E tests
* Merge'd
* Add restricted DM check to more places
* Merge'd
* Restrict patching the channel (updating the channel)
* Update verbiage in the admin console
* Fix lint
* More tests
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* Mirror Postgres 14 docker image (#34009)
* ugprade to go 1.24.6 (#34004)
* Bump Postgres minimum supported version to 14 (#34010)
* Downgrade French language (#33826)
* Downgrade French language
* Update i18n.jsx
* Updates buildFieldAttrs to preseve existing attrs when editing a field (#33991)
* Updates buildFieldAttrs to preseve existing attrs when editing a field
* Fix preserve option issue for select/multiselect type fields
* Fix linter
---------
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
* MM-64423 - Removing the clear func on switch (#31214)
* MM-64423 - Removing the clear func on switch
* Select all teams by default
* Updating test
* Updating test
* Removing showFilterHaveBeenReset
* Removing search string
* Do not clear the search term
* Updating tests
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* Mm 65123 remove channel abac ff (#33953)
* MM-65123 - remove channel abac feature flag
* enable the channel scope access control to true
* fix linters
* adjust expected error in tests
* remove no longer needed comment
* Remove write_restrictable from core ABAC settings and fix channel access control logic
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* [MM-65837], [MM-65824] - Update Dependencies (#33972)
* Update github.com/mholt/archives
* Update github.com/spf13/viper
* make batch migration worker tests less flaky
---------
Co-authored-by: Jesse Hallam <jesse@mattermost.com>
* (a11y-test): team menu (#33998)
* MM-66071: Do not error on empty slice in /groups/names (#34021)
* Do not error on empty slice in /groups/names
If group_names is an empty slice, this should not be an invalid
parameter. We return what we were asked for: an empty array.
* Avoid requests to /groups/names if list is empty
If the list of group names is empty, we do not need to ask the server
for the corresponding groups: we already know it'll be an empty list.
* Fix ABAC not available for entry (#34027)
Automatic Merge
* Explicitly name Postgres container volume (#33954)
* Explicitly name Postgres container volume
* Remove unused server/docker-compose.yaml
This file doesn't seem to actually be used. When we run docker compose locally,
it uses docker-compose.makefile.yml merged with the output of
build/docker-compose-generator/main.go.
* Revert "Remove unused server/docker-compose.yaml"
This reverts commit
|
||
|---|---|---|
| .. | ||
| src | ||
| .eslintrc.json | ||
| babel.config.js | ||
| jest.config.js | ||
| package.json | ||
| README.md | ||
| setup_jest.ts | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
Mattermost Client
This package contains the JavaScript/TypeScript client for Mattermost. It's used by the Mattermost web app and related projects.
Installation
JavaScript
$ npm install @mattermost/client
TypeScript
$ npm install @mattermost/client @mattermost/types
Usage
Rest Client
To use this client, create an instance of Client4, set the server URL, and log in, and then you can start making requests.
import {Client4} from '@mattermost/client';
const client = new Client4();
client.setUrl('https://mymattermostserver.example.com');
client.login('username', 'password').then((user) => {
// ...
});
If you already have a session token or a user access token, you can call Client4.setToken instead of logging in.
import {Client4} from '@mattermost/client';
const client = new Client4();
client.setUrl('https://mymattermostserver.example.com');
client.setToken('accesstoken');
If needed, methods exist to set other headers such as the User-Agent (Client4.setUserAgent), the CSRF token (Client4.setCSRF), or any extra headers you wish to include (Client4.setHeader).
Methods of Client4 which make requests to the server return a Promise which does the following:
- On success, the promise resolves to a
ClientResponse<T>object which contains the the Response (response), a Map of headers (headers), and the data sent from the server (data). - On an error, the promise rejects with a
ClientErrorwhich contains the error message and the URL being requested. If the error happened on the server, the status code and an error ID (server_error_id) are included.
let user;
try {
user = (await client.getUser('userid')).data;
} catch (e) {
console.error(`An error occurred when making a request to ${e.url}: ${e.message}`);
}
WebSocket Client
To use the WebSocket client, create an instance of WebSocketClient and then call its initialize method with the connection URL and an optional session token or user access token. After that, you can call the client's addMessageListener method to register a listener which will be called whenever a WebSocket message is received from the server.
import {WebSocketClient} from '@mattermost/client';
// If you already have an instance of Client4, you can call its getWebSocketUrl method to get this URL
const connectionUrl = 'https://mymattermostserver.example.com/api/v4/websocket';
// In a browser, the token may be passed automatically from a cookie
const authToken = process.env.TOKEN;
const wsClient = new WebSocketClient();
wsClient.initialize(connectionUrl, authToken);
wsClient.addMessageListener((msg) => {
if (msg.event === 'posted') {
console.log('New post received', JSON.parse(msg.data.post));
}
});
Node.js
Note that WebSocketClient expects globalThis.WebSocket to be defined as it was originally written for use in the Mattermost web app. If you're using it in a Node.js environment, you should set globalThis.WebSocket before instantiating the WebSocketClient.
import WebSocket from 'ws';
if (!globalThis.WebSocket) {
globalThis.WebSocket = WebSocket;
}
const wsClient = new WebSocketClient();
This can also be done using dynamic imports if you're using them.
if (!globalThis.WebSocket) {
const {WebSocket} = await import('ws');
globalThis.WebSocket = WebSocket;
}
const wsClient = new WebSocketClient();
Compilation and Packaging
As a member of Mattermost with write access to our NPM organization, you can build and publish this package by running the following commands:
npm run build --workspace=platform/client
npm publish --workspace=platform/client
Make sure to increment the version number in package.json first! You can add -0, -1, etc for pre-release versions.