Coder Social home page Coder Social logo

mattermost-redux's Introduction

Mattermost Redux is now located at mattermost/mattermost-webapp

This repository is being left open for the time being while we set up proper monorepo infrastructure to be able to release mattermost-redux from there, but it will be archived once that has been set up.

New releases of mattermost-redux will be on hold while that is done, but feel free to continue using existing versions.


Mattermost Redux CircleCI branch

The project purpose is consolidating the storage, web utilities and logic of the webapp and React Native mobile clients into a single driver. We encourage you to use mattermost-redux to power your own Mattermost clients or integrations.

Redux is the backbone for this project and many of the design decisions and patterns stem from it.

Mattermost is an open source Slack-alternative used by thousands of companies around the world in more than 16 languages. Learn more at https://mattermost.com.

Usage

Basic Usage

To hook up your application to the mattermost-redux store:

import configureServiceStore from 'mattermost-redux/store';

configureServiceStore(yourInitialState, yourAppReducers);

const store = configureStore();

// use store
  • yourInitialState - any initial state for any extra reducers you may have (set to {} if none)
  • yourAppReducers - any reducers from your app (set to {} if none)

Web Client Usage

If you're only looking to use the v4 JavaScript web client for the Mattermost server:

With async/await:

import {Client4} from 'mattermost-redux/client';

Client4.setUrl('https://your-mattermost-url.com');

async function loginAndGetUser(username, password) {
    try {
        await Client4.login(username, password);
    } catch (error) {
        console.error(error);
        return null;
    }

    let user;
    try {
        user = await Client4.getMe();
    } catch (error) {
        console.error(error);
        return null;
    }

    return user;
}

With promises:

import {Client4} from 'mattermost-redux/client';

Client4.setUrl('https://your-mattermost-url.com');

function loginAndGetUser(username, password, callback) {
    Client4
        .login(username, password)
        .then(Client4.getMe)
        .then(callback)
        .catch(console.error);
}

If you already have a personal access token or session token, you can set the token manually instead of logging in:

import {Client4} from 'mattermost-redux/client';

Client4.setUrl('https://your-mattermost-url.com');
Client4.setToken(yourToken);

Browser Usage

To build a browser-compatible client via webpack:

$ git clone <this repo>
$ cd mattermost-redux
$ make bundle

This will generate lib/mattermost.client4.js, and lib/mattermost.websocket.js which can be loaded in a browser. Also note that babel-polyfill is required.

<script src="/path/to/babel/polyfill.js"></script>
<script src="/path/to/mattermost.client4.js"></script>
<script src="/path/to/mattermost.websocket.js"></script>
<script type="text/javascript">
    const client = Mattermost.client4.default();
    const wsClient = Mattermost.websocket.default;
    var token;
    client.setUrl('https://your-mattermost-url.com');
    /* use an existing personal access token */
    client.setToken('yourToken');
    client.setIncludeCookies(false);
    /* login and obtain a token */
    client.login(username, password)
    .then(function(user){
        console.log(`Logged in as ${user.email}`);
        token = client.getToken();
    })
    .then(function(){
        wsClient.initialize(token, {}, {}, {connectionUrl: 'wss://your-mattermost-url.com/api/v4/websocket'});
    })
    .catch(function(err){
        console.error(err);
    });
</script>

node.js Usage

Running the client from node.js requires making the fetch and WebSocket packages globally available, and the use of babel-polyfill:

require('babel-polyfill');
require('isomorphic-fetch');
if (!global.WebSocket) {
    global.WebSocket = require('ws');
}
const Client4 = require('./client/client4.js').default;
const client = new Client4;
const wsClient = require('./client/websocket_client.js').default;
var token;

wsClient.setEventCallback(function(event){
    console.log(event);
});

client.setUrl('https://your-mattermost-url.com');
client.login(username, password)
.then(function(me){
    console.log(`logged in as ${me.email}`);
    token = client.getToken();
})
.then(function(){
    wsClient.initialize(token, {}, {}, {connectionUrl: 'wss://your-mattermost-url.com/api/v4/websocket'});
})
.catch(function(err){
    console.error(err);
});

How to Contribute

How to Build mattermost-redux

You only need to build mattermost-redux if you are developing it.

Webapp Development

If your mattermost-webapp and mattermost-redux are in the same directory, you only need to run npm run dev or npm run dev:watch.

If you have mattermost-webapp in other directory or you are developing your own application, you can define the environment variable WEBAPP_DIR to change the destination app (e. g. WEBAPP_DIR=/tmp/mattermost-webapp).

React Native (Mobile) Development

If your mattermost-mobile and mattermost-redux are in the same directory, you only need to run npm run dev-mobile or npm run dev-mobile:watch.

If you have mattermost-mobile in other directory or you are developing your own application, you can define the environment variable MOBILE_DIR to change the destination app (e. g. MOBILE_DIR=/tmp/mattermost-mobile).

Resetting apps to use package redux

If you want to go back to using the package specified redux in your web or mobile app you can stop the server and run rm -rf .npminstall to force your project to reset to the specified package version on next server start.

Contribute Code

If you're contributing to help migrate the webapp to Redux go ahead and submit your PR. If you're just fixing a small bug or adding a small improvement then feel free to submit a PR for it. For everything else, please either work on an issue labeled [Help Wanted] or open an issue if there's something else that you'd like to work on.

Feel free to drop by the Redux channel on our Mattermost instance.

Running the Tests

make test will run the unit tests against a mocked server.

mattermost-redux's People

Contributors

catalintomai avatar ccbrown avatar chetanyakan avatar cometkim avatar cpanato avatar crspeller avatar csduarte avatar dependabot[bot] avatar devinbinnie avatar enahum avatar fmunshi avatar grundleborg avatar hahmadia avatar hanzei avatar hmhealey avatar jarredwitt avatar jasonblais avatar jespino avatar jwilander avatar lieut-data avatar mgdelacroix avatar migbot avatar mkraft avatar nevyangelova avatar pradeepmurugesan avatar reflog avatar saturninoabril avatar stephenkiers avatar sudheerdev avatar willyfrog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mattermost-redux's Issues

CORS issue with Client4, can't get localhost:3000 to communicate with localhost:8065

Summary

CORS issue with Client4, does not allow localhost:3000 to access localhost:8065.
Seems similar to #557 , but I still can't figure.

Environment Information

  • Chrome Version 69.0.3497.100 (Official Build) (64-bit)
  • Webapp
  • Mattermost Server 5.4.0
  • Docker Version 18.06.1-ce-win73 (19507), running in Windows 10 Pro

Steps to reproduce

  • Set up Mattermost on Docker, runs on localhost:8065
  • create-react-app runs on localhost:3000
  • Try to call Client4.getMe():
    import {Client4} from 'mattermost-redux/client';

    Client4.setUrl('<https://your-mattermost-url.com>');

    async function loginAndGetUser(username, password) {
        try {
            await Client4.login(username, password);
        } catch (error) {
            console.error(error);
            return null;
        }

        let user;
        try {
            user = await Client4.getMe();
        } catch (error) {
            console.error(error);
            return null;
        }

        return user;
    }

Expected behavior

Getting the results from the server.

Observed behavior

Failed to load http://localhost:8065/api/v4/users/login: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Possible fixes

I installed the Allow-Control-Allow-Origin Chrome extension, and added http://localhost:3000 in the Access-Control-Expose-Header option.
Then the Chrome error message is:
Failed to load http://localhost:8065/api/v4/users/login: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access.

Final Note

I am able to get a response with below, at least I know the server works well:
curl -i -d "{\"login_id\":\"<[email protected]>\",\"password\":\"<MyPassword>\"}" http://localhost:8065/api/v4/users/login

ReferenceError: Can't find variable: Reflect

Summary

login error

Environment Information

  • React Native: 0.48.3
  • Mattermost Server Version: 4.2.0

Steps to reproduce

When I try to login, it go wrong.

Expected behavior

App launches successfully.

Observed behavior

Cannot logined Mattermost Server.

Possible fixes

code:
async loginAndGetUser(username, password) {
try {
await Client4.login(username, password);
} catch (error) {
console.error('====login=======' , error);
return null;
}
let user;
try {
user = await Client4.getMe();
} catch (error) {
console.error('=====getMe========', error);
return null;
}
return user;
}

error

09-20 17:48:46.898 21364 21453 E ReactNativeJS: '====login=======', { [ReferenceError: Can't find variable: Reflect]
09-20 17:48:46.898 21364 21453 E ReactNativeJS: line: 55746,
09-20 17:48:46.898 21364 21453 E ReactNativeJS: column: 19,
09-20 17:48:46.898 21364 21453 E ReactNativeJS: sourceURL: 'http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false' }

Reactions broken on subpath installation of Mattermost

Summary

mattermost-redux does not take into account Site URL configured in Mattermost Server.

Environment Information

  • Webapp or React Native app: Webapp
  • Mattermost Server Version: 5.1.0

Steps to reproduce

Expected behavior

Emojis should be rendered correctly with respect to the Site URL.

Observed behavior

image

Possible fixes

URL is generated here: https://github.com/mattermost/mattermost-redux/blob/master/src/utils/emoji_utils.js#L18

uploadFile not working. Content type not set in upload function

Submit feature requests to http://www.mattermost.org/feature-requests/. File non-security related bugs here in the following format:

Summary

Issue in one concise sentence.

Environment Information

  • Webapp or React Native app:
  • Mattermost Server Version:

Steps to reproduce

How can we reproduce the issue?

Expected behavior

Describe your issue in detail.

Observed behavior

What did you see happen? Please include relevant error messages and/or screenshots.

Possible fixes

If you can, link to the line of code that might be responsible for the problem.

Why the timestamp of messages based on platform?

Submit feature requests to http://www.mattermost.org/feature-requests/. File non-security related bugs here in the following format:

Summary

I confused why the timestamp of messages based on platform? (only if the login user is admin)

Environment Information

  • React Native app: beta
  • Mattermost Server Version: 3.9.0

Steps to reproduce

  1. Login as Admin
  2. change iPhone's Data&Time
  3. post a message

Expected behavior

mattermost-redux/src/actions/posts.js

const timestamp = Date.now();
...
  create_at: timestamp,
  update_at: timestamp

Observed behavior

The timestamp of this Message is based on iPhone's not sever's

Possible fixes

type definition of Client4 don't match api definition

Submit feature requests to http://www.mattermost.org/feature-requests/. File non-security related bugs here in the following format:

Summary

type definition of Client4 don't match api definition on api.mattermost.com

Environment Information

  • Webapp or React Native app: Webapp
  • Mattermost-redux Version: 5.18.0

Steps to reproduce

Try to make use of the createPost function with a structure only containing:

  • channel_id
  • message
  • props

This is only one example. Another is the mandatory timestamp attribute for the getFileThumbnailUrl and getFileUrl, while neither according to the documentation, nor the javascript code make it mandatory.

Expected behavior

Post creation endpoint is invoked.

Observed behavior

The code cannot compile since it expects a full post object, including all the date fields (create, update, ...)

Possible fixes

Revert to typing of 5.17.0.

Remove offline features from library

Summary

The library depends on:

  • redux-offline
  • @react-native-community/netinfo

Because working with offline is the responsibility of the mobile application only, I suggest remove offline code from the library.

Update to isomorphic-fetch 3.x to resolve vulnerability in transitive dependency node-fetch

Summary

Update to isomorphic-fetch 3.x to resolve vulnerability in transitive dependency node-fetch 1.7.3

Steps to reproduce

Run npm audit in a project that has "mattermost-redux": "5.28.1" as dependency.

Expected behavior

There are no security vulnerabilities related to mattermost-redux.

Observed behavior

A vulnerability is indicated that cannot be resolved automatically:

  Low             Denial of Service                                             
                                                                                
  Package         node-fetch                                                    
                                                                                
  Patched in      >=2.6.1 <3.0.0-beta.1|| >= 3.0.0-beta.9                       
                                                                                
  Dependency of   mattermost-redux                                              
                                                                                
  Path            mattermost-redux > isomorphic-fetch > node-fetch              
                                                                                
  More info       https://npmjs.com/advisories/1556                

Possible fixes

Update isomorphic-fetch to latest version.

Missing release for removing `redux-offline`

Summary

It looks like redux-offline was already removed from the web app, so the actions in this package relying on it don't work anymore.

Environment Information

  • Webapp or React Native app: Web
  • Mattermost Server Version: mattermost-enterprise-edition:5.35.0
  • mattermost-redux Version: 5.33.1

Steps to reproduce

Create a plugin that uses the createPost action or any other action that depended on redux-offline.

Expected behavior

No API request to create the post is sent, and the post stays pending indefinitely on the creating client's side.

Observed behavior

The API request to create the post is sent, the post is persistet and visible for all members of the channel.

Possible fixes

If I'm not mistaken, this problem is caused by removing redux-offline in these PRs:

and changing mattermost-webapp to use its own version in this PR: mattermost/mattermost-webapp#7723

While I get the point of doing this, it looks like there was never a release of mattermost-redux that also removes redux-offline, as it's still bundled in the latest 5.33.1 release. This breaks plugins that e.g. use createPost from mattermost-redux, as the code still includes this part:

// ...
dispatch({
    type: action_types_1.PostTypes.RECEIVED_NEW_POST,
    data: tslib_1.__assign(tslib_1.__assign({}, newPost), { id: pendingPostId }),
    meta: {
        offline: {
            effect: function () {
                return client_1.Client4.createPost(tslib_1.__assign(tslib_1.__assign({}, newPost), { create_at: 0 }));
            },
// ...

As redux-offline was removed from the web app and doesn't look to be bundled with mattermost-redux, the meta.offline part is simply never executed.

This could be somewhat "fixed" by releasing this change for mattermost-redux, however that would still mean plugins relying on these actions that are not updated would remain broken.

Addendum: I can comfirm that building mattermost-redux from the current master of this repo and using those files instead of npm installing mattermost-redux in a plugin successfully works around this issue - not the best idea tho, IMO.

Running React Native app with mattermost-redux fails.

Summary

Running React Native app with mattermost-redux fails.

Steps to reproduce

  • npm i mattermost-redux --save
  • react-native run-ios

Expected behavior

The React Native app should start without error.

Observed behavior

error: bundling failed: Error: Unable to resolve module core-js/modules/web.dom-collections.iterator from /Users/node_modules/mattermost-redux/store/configureStore.dev.js: Module core-js/modules/web.dom-collections.iterator does not exist in the Haste module map

Possible fixes

Install additional deps

  • @react-native-community/netinfo
  • core-js
  • remote-redux-devtools

npm [email protected] is missing built files

Summary

npm [email protected] is missing built files

Steps to reproduce

npm install [email protected]

Expected behavior

Same basic set of files as for version 5.29.1 which is:

contents of node_modules/mattermost-redux@5.29.1

drwxrwxr-x  2 user user   4096 Feb 23 15:59 action_types/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 actions/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 client/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 constants/
drwxrwxr-x  3 user user   4096 Feb 23 15:59 node_modules/
drwxrwxr-x  5 user user   4096 Feb 23 15:59 reducers/
drwxrwxr-x  3 user user   4096 Feb 23 15:59 selectors/
drwxrwxr-x 11 user user   4096 Feb 23 15:59 src/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 store/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 types/
drwxrwxr-x  2 user user   4096 Feb 23 15:59 utils/
-rw-rw-r--  1 user user    609 Oct 26  1985 CONTRIBUTING.md
-rw-rw-r--  1 user user  11399 Oct 26  1985 LICENSE.txt
-rw-rw-r--  1 user user  30298 Oct 26  1985 NOTICE.txt
-rw-rw-r--  1 user user   6430 Oct 26  1985 README.md
-rw-rw-r--  1 user user   2014 Oct 26  1985 SECURITY.md
-rw-rw-r--  1 user user 205833 Oct 26  1985 mattermost.client4.js
-rw-rw-r--  1 user user 779845 Oct 26  1985 mattermost.client4.js.map
-rw-rw-r--  1 user user   4759 Oct 26  1985 mattermost.websocket_client.js
-rw-rw-r--  1 user user  23716 Oct 26  1985 mattermost.websocket_client.js.map
-rw-rw-r--  1 user user   4661 Feb 23 15:59 package.json
-rw-rw-r--  1 user user   1394 Oct 26  1985 rollup.config.js
-rw-rw-r--  1 user user   2039 Oct 26  1985 tsconfig.json

Although I'm not sure why the src directory is included in the package.

Observed behavior

Notice all of the missing build directories (eg. action_types, actions, client etc.)

contents of node_modules/mattermost-redux@5.29.2

drwxrwxr-x  3 user user  4096 Feb 23 16:40 node_modules/
drwxrwxr-x 11 user user  4096 Feb 23 16:40 src/
-rw-rw-r--  1 user user   609 Oct 26  1985 CONTRIBUTING.md
-rw-rw-r--  1 user user 11399 Oct 26  1985 LICENSE.txt
-rw-rw-r--  1 user user 30298 Oct 26  1985 NOTICE.txt
-rw-rw-r--  1 user user  6430 Oct 26  1985 README.md
-rw-rw-r--  1 user user  2014 Oct 26  1985 SECURITY.md
-rw-rw-r--  1 user user  4661 Feb 23 16:40 package.json
-rw-rw-r--  1 user user  1394 Oct 26  1985 rollup.config.js
-rw-rw-r--  1 user user  2039 Oct 26  1985 tsconfig.json

Possible fixes

I'm not sure what the normal process that publishes the mattermost_redux package is, but it looks like it was supposed to be built first and wasn't.

Login does not save token

Summary

Calling the "login" method does not set the token (anymore?).
The example in the readme suggests that it should:

client.setUrl('https://your-mattermost-url.com');
client.login(username, password)
.then(function(me){
    console.log(`logged in as ${me.email}`);
    token = client.getToken(); // empty!
})

Steps to reproduce

Execute the example code with valid server URL and credentials (username and password).

Expected behavior

I expect the token to be stored in the client.
If the login is done with a password, the token received from Mattermost server in response header should be saved.
If the login is done with a token, the used token should be saved.

Observed behavior

Subsequent API actions want me to authenticate again. I can't use the API using this library with username and password.

Possible fixes

I guess somewhere around https://github.com/mattermost/mattermost-redux/blob/master/src/client/client4.ts#L658, but I don't know where to get the response header.

My current workaround: Send a separate login via Axios to get the token.

Installing mattermost-redux for a global package fails

Summary

Installation of mattermost-redux fails due to git dependency.

Steps to reproduce

  • sudo npm i -g mattermost-redux

Expected behavior

The module should install without error.
The issue occurs if you want to install a package (for example an cli) which uses mattermost-redux globally.

Observed behavior

npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/enahum/redux-offline.git /root/.npm/_cacache/tmp/git-clone-f7f32218
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-f7f32218': Permission denied
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-02-12T14_40_06_244Z-debug.log

Possible fixes

  • Remove the redux-offline dependency as git based dependency. If you must use your own version of this package, at least publish it to npm.
  • Split mattermost-redux into different packages. The idea with npm is that packages are small. This package now contains both the client and usages of the client. I propose to at least create mattermost-http-client and mattermost-ws-client as packages. Note: you can still keep the code in one repo.

The latest npm (v1.2.0) is not sync with the latest code(now at tag v5.2.0)

Summary

Issue in one concise sentence.

Environment Information

  • mattermost/mattermost-redux

Steps to reproduce

The latest npm project mattermost-redux(v1.2.0) is not sync with the latest code(now at tag v5.2.0).

Expected behavior

The npm project is sync with the github code or mention Please don't use npm since they are not maintained in Readme file.

Thank you! I want to mention that because it takes time to figure it out.

Promise returned from wsClient.initialize doesn't resolve on connect

Summary

Mattermost websocket client (client/websocket_client.js) initialize method does not resolve its returned promise if a firstConnectCallback function property is not set.

Environment Information

  • Webapp or React Native app: N/A
  • Mattermost Server Version: 4.7.1

Steps to reproduce

Using the node.js Usage steps highlighted in the README, add an additional promise chain then block after the wsClient.initialize call. The returned promise from initialize only resolves if a firstConnectCallback is set.

// ...
.then(function(){
    return wsClient.initialize(token, {}, {}, {connectionUrl: 'wss://your-mattermost-url.com/api/v4/websocket'});
})
.then(function() {
  console.log('wsClient.initialize method resolved its promise!')
})
// ...

Expected behavior

The initialize method returns a Promise that should resolve when the websocket connection is complete and successful.

Observed behavior

Any promise resolve method does not execute when the websocket does successfully finish connecting.

Possible fixes

Line 104 in src/client/websocket_client.js creates a conditional that is ultimately responsible for executing the promise resolve when the websocket connects, but can only execute if a firstConnectCallback function is set and exists.

Without chrome extension Redux Dev Tools the webapp throws errors

Summary

If you don't have the chrome extension Redux Dev Tools installed you get a whole bunch of errors (see below) that cause the webapp to "explode" in development.

image pasted at 2017-12-13 10-28

Environment Information

  • Webapp: ?
  • Mattermost Server Version: ?

Steps to reproduce

Install the webapp dev environment without Redux Dev Tools installed.

Expected behavior

Would be nice to have this disabled by default and or more gracefully handle these errors.

Observed behavior

Error messages (see screenshot above).

Possible fixes

In configureStore.dev.js there is a bunch of stuff regarding remote-redux-devtools. More specifically look into disabling the tools if window.__REDUX_DEVTOOLS_EXTENSION__ doesn't exist. See these lines of code:

typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ ? // eslint-disable-line no-underscore-dangle
window.__REDUX_DEVTOOLS_EXTENSION__ : // eslint-disable-line no-underscore-dangle
() => {
return devTools({
name: 'Mattermost',
hostname: 'localhost',
port: 5678,
realtime: true
});

Updated dependency fails RN app

Summary

Recent version bump (d4b6552) to serialize-errors prevents RN app from running.

Steps to reproduce

mattermost-redux: With current HEAD on master (2289b68):

  • make clean
  • make

mattermost-mobile: With current HEAD on master (mattermost/mattermost-mobile@e5e3bcc):

  • make clean
  • make pre-run
  • make run-ios/run-android

With these steps, the mobile app should fail when building bundle with the following redbox:

Screen Shot 2019-11-13 at 10 19 21

Possible fixes

So, this recent commit prevents RN app master from building, if it is pointed to latest mattermost-redux commit.

We've had the same issue before, but this time I can't just do a simple revert because there's a pre-commit hook fails the implicit anys rule for library dependencies. This prevents the serialize-error library from going back to an older version.

I'm looking at options, including possibly removing serialize-error, but this is a more involved effort. Another option could be to somehow not run the pre-commit hook on dependency libraries?

Unable to join channel via slash command using channel name with tilde

Submit feature requests to http://www.mattermost.org/feature-requests/. File non-security related bugs here in the following format:

Summary

When I try to use the slash command like so: /join ~off-topic it fails.

Environment Information

  • Webapp or React Native app: Webapp
  • Mattermost Server Version: 5.0.0

Steps to reproduce

  1. Try to join a channel with the following command: /join ~off-topic

Expected behavior

/join command works. Please note that it DOES work if you do /join off-topic.

Observed behavior

  1. Notice you get system message "An error occurred while listing channels"
  2. Notice logs:
    {"level":"error","ts":1531408785.8157103,"caller":"web/handlers.go:140","msg":"You do not have the appropriate permissions","path":"/api/v4/channels/4a611cw6w3gy7rna3zaukcq1xa/members/me","request_id":"rkr8zjsmqi85jrnrxkbrdhqh9r","ip_addr":"172.17.0.1","user_id":"drxfunkhzbf3dkuit35zrnmsrh","method":"GET","err_where":"Permissions","http_code":403,"err_details":"userId=drxfunkhzbf3dkuit35zrnmsrh, permission=read_channel"}

Possible fixes

It seems likely to me it has something to do with the logic here: https://github.com/mattermost/mattermost-redux/blob/master/src/actions/channels.js#L664 where if it gets the channel name it does one thing (which I think is the case that works) and if it gets the channel id (which it makes sense if you use tilde then it finds the channel id and tries to post that instead) it does another thing. Why it's trying to list members first before adding (which is what it seems to be doing) I don't know.

Rudderlabs sets cookie for whole domain

Summary

Rudderlabs cookies set on domain .example.com, not on mattermost.example.com.

Environment Information

  • Webapp or React Native app: Webapp
  • Mattermost Server Version: latest

Steps to reproduce

Install Mattermost on a server. Use a subdomain, e.g. https://mattermost.example.com. Visit that domain. Observe that the JS application (the 5MB main.js) sets two cookies, rl_user_id and rl_anonymous_id for the domain .example.com.

Now visit https://example.com, or https://gitlab.example.com. Observe the same cookies sent to these domains as well.

Bonus: have a development machine reachable at http://dev-42.vpn.example.com. Observe a lot of warnings for these cookies.

Expected behavior

The Rudderlabs cookies should only be set for mattermost.example.com.

Observed behavior

See above. The cookies are setup to be tracking cookies for the whole domain, including all subdomains.

Possible fixes

Confine Rudderlabs cookies to the (sub) domain Mattermost is installed on.

If that's not possible, remove Rudderlabs altogether.

report redux utils not found error when build Mattermost-webapp

Summary

report mattermost-redux/utils/user_utils.jsx not found error when build Mattermost-webapp

Environment Information

OS X 10.14.4

  • Webapp or React Native app: 5.9
  • Mattermost Server Version: 5.9
  • node version: 10.15.3&8.12.0

Steps to reproduce

cd /path/to/mattermost/mattermost-webapp/
sudo npm install --unsafe-perm --allow-root
sudo npm run build

Error detail

[/Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/mattermost-redux/utils/user_utils.jsx]
 @ ./components/user_settings/security/user_access_token_section/user_access_token_section.jsx 39:0-63 195:11-34
 @ ./components/user_settings/security/user_access_token_section/index.js
 @ ./components/user_settings/security/user_settings_security.jsx
 @ ./components/user_settings/security/index.js
 @ ./components/user_settings/user_settings.jsx
 @ ./node_modules/babel-loader/lib??ref--4!./components/user_settings/index.js
 @ ./node_modules/bundle-loader?lazy!./components/user_settings/index.js
 @ ./components/user_settings/modal/user_settings_modal.jsx
 @ ./components/user_settings/modal/index.js
 @ ./components/profile_popover/profile_popover.jsx
 @ ./components/profile_popover/index.js
 @ ./components/at_mention/at_mention.jsx
 @ ./components/at_mention/index.jsx
 @ ./utils/message_html_to_component.jsx
 @ ./plugins/export.js
 @ ./components/root/root.jsx
 @ ./node_modules/babel-loader/lib??ref--4!./components/root/index.js
 @ ./node_modules/bundle-loader?lazy!./components/root/index.js
 @ ./root.jsx
 @ multi @babel/polyfill whatwg-fetch url-search-params-polyfill ./root.jsx root.html

ERROR in ./utils/utils.jsx
Module not found: Error: Can't resolve 'mattermost-redux/utils/user_utils' in '/Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/utils'
resolve 'mattermost-redux/utils/user_utils' in '/Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/utils'
  Parsed request is a module
  using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: ./utils)
    resolve as module
      /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/utils/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/utils/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/github.com/mattermost/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/github.com/mattermost/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/github.com/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/github.com/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/src/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/go/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/node_modules doesn't exist or is not a directory
      /Users/zack/godev_centos_docker/non_npm_dependencies doesn't exist or is not a directory
      /Users/zack/node_modules doesn't exist or is not a directory
      /Users/zack/non_npm_dependencies doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /Users/non_npm_dependencies doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      /non_npm_dependencies doesn't exist or is not a directory
      looking for modules in /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules
        using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: ./node_modules)
          using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules/mattermost-redux/package.json (relative path: ./utils/user_utils)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules/mattermost-redux/utils/user_utils doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules/mattermost-redux/utils/user_utils.js doesn't exist
            .jsx
              Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/non_npm_dependencies
        using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: ./non_npm_dependencies)
          using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: ./non_npm_dependencies/mattermost-redux/utils/user_utils)
            no extension
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/non_npm_dependencies/mattermost-redux/utils/user_utils doesn't exist
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules/mattermost-redux/utils/user_utils.jsx doesn't exist
            .js
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/non_npm_dependencies/mattermost-redux/utils/user_utils.js doesn't exist
            as directory
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/node_modules/mattermost-redux/utils/user_utils doesn't exist
            .jsx
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/non_npm_dependencies/mattermost-redux/utils/user_utils.jsx doesn't exist
            as directory
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/non_npm_dependencies/mattermost-redux/utils/user_utils doesn't exist
      looking for modules in /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp
        using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: .)
          using description file: /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/package.json (relative path: ./mattermost-redux/utils/user_utils)
            no extension
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/mattermost-redux/utils/user_utils doesn't exist
            .js
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/mattermost-redux/utils/user_utils.js doesn't exist
            .jsx
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/mattermost-redux/utils/user_utils.jsx doesn't exist
            as directory
              /Users/zack/godev_centos_docker/go/src/github.com/mattermost/mattermost-webapp/mattermost-redux/utils/user_utils doesn't exist

Observed behavior





 checked the Mattermost-redux in node_modules, the utils folder is inside src, so the correct path is /path/to/mattermost/mattermost-webapp/node_modules/mattermost-redux/src/utils/user_utils.jsx

====================

update

its okay in my windows 10, and the path is correct in node_modules, such as /path/to/mattermost/mattermost-webapp/node_modules/mattermost-redux/utils/user_utils.jsx

solved on Mac os x

its okay after 

run npm cache clean --force on my Mac os X

solved finnally

# in mattermost-webapp folder
npm install

# go to install dependencies manually for mattermost-redux
cd node_modules/mattermost-redux
npm install
cd ../..

# then build success
npm run build

groups types

Related issue:
mattermost/mattermost#16734

  1. export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReference: false, includeMemberCount: false): ActionFunc {

    filterAllowReference and includeMemberCount should be of type boolean?

  2. scheme_admin: boolean;

    scheme_admin prop should be optional?
    Here:
    https://github.com/mattermost/mattermost-webapp/blob/23343c2f1614d61d8f326d60d3730f97b89c94b6/components/add_groups_to_team_modal/add_groups_to_team_modal.jsx#L132
    it is omitted

[perf] localeCompare is slow & proposed fix

Summary

String.localeCompare function is very very slow.
Do V8 devs know about it?
Yes, it's been at their bugtracker for a long time, they won't 'fix' it.

It's used here to sort the channels, which happens very often, for example when switching channels.
I personally have a lot of channels, mainly as archive, but since they are private channels I can't quit them like public channels so they get off the navbar.
(40 navbar items)

It's hard for me to get the exact numbers, but I guarantee it's not less than 10% of channel switch time.
I understand it's there to support Chineese and sorting non-latin stuff but we can at least use a fast regex before calling localeCompare like [a-zA-Z0-9!@#$^&*()] something close to that.
Maybe even a for-each-char loop that checks if the char is within ASCII range.
If not, only then use localeCompare.

This could also be a visible improvement on the mobile app channel switching and I am curious to know this, if you guys have good tooling to check.

Would that be fine?

For now I injected this piece of code to my mattermost-webapp and enjoyed better channel switch time:

String.prototype.localeCompare = function(b) { var a = this;   return (a < b ? -1 : (a > b ? 1 : 0));}

Environment Information

  • Webapp or React Native app:
  • Mattermost Server Version:

Steps to reproduce

How can we reproduce the issue?
Have lots of channels in navbar and switch channel.

Expected behavior

Describe your issue in detail.
Channel switching is fast.

Observed behavior

What did you see happen? Please include relevant error messages and/or screenshots.
Channel switching is slower than it could be.

Possible fixes

If you can, link to the line of code that might be responsible for the problem.
If two strings are within ASCII range use a simple compare and not localeCompare.

When uploading multiple images with same timestamp, the redux fails

After this PR #582 is merged we have problem in 5.2 if multiple images in same post are uploaded at the same timestamp
screen shot 2018-08-28 at 16 21 48

For some reason the original postid is "locale". I tried to debug this problem but could not find why the locale is postid. Anyways all images has locale = postid instead of real locale. The problem exists only if two images has exact same timestamp. Then it is trying to do localeCompare in https://github.com/mattermost/mattermost-redux/blob/master/src/utils/file_utils.js#L97 but fails because the locale variable is postid.

CORS not working with Client4

Summary

CORS seem to fail with Client4 although mattermost-server has AllowCorsFrom set to "*"

Environment Information

  • Chrome 65
  • Webapp
  • Mattermost Server 5.0.0

Steps to reproduce

Try to call Client4.getMe()

Expected behavior

Getting the results from the server.

Observed behavior

Chrome says: Failed to load http://localhost:8065/api/v4/users/me: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:8081' is therefore not allowed access.

A simple test posted here:
mattermost/mattermost#8687
using fetch (fetch('http://localhost:8065/api/v4/system/ping')) works.

How to remove / delete a uploaded file from mattermost-server ?

Submit feature requests to http://www.mattermost.org/feature-requests/. File non-security related bugs here in the following format:

Summary

How to remove / delete a uploaded file from mattermost-server ?

Environment Information

  • Webapp or React Native app: Webapp
  • Mattermost Server Version:4.5.

Steps to reproduce

Upload file
mattermostClient.uploadFile(imageFormData)
Get file
mattermostClient.getFile(fileId)

There is function available for delete the file

Expected behavior

Upload file
mattermostClient.uploadFile(imageFormData)
Get file
mattermostClient.getFile(fileId)
Remove file
mattermostClient.removeFile(fileId)

Observed behavior

There is no function to do this task.

Possible fixes

If you can, link to the line of code that might be responsible for the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.