* MM-30289 Detox/E2E - Add e2e tests for MM-T3184 and MM-T3186
* Update detox/e2e/support/server_api/preference.js
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
* MM-31322: redirect permalink handler (#5136)
* invert loadTeam.error test
* MM-31322: handle _redirect permalinks
In the webapp, [there is support](7c5a2e3bfd/components/root/root.jsx (L345-L352)) for a special `_redirect` team name in certain contexts that simply means, "the current team". It's used in the context of redirecting to the integrations backstage (not relevant for mobile), for also for resolving post permalinks.
This simplifies certain kinds of integrations which no longer have to know a team name to render a permanent link to a post. An example link looks like:
http://localhost:8065/_redirect/pl/e3sxrxtwh78jmxawsaqfemxoew
This PR adds support for same in mobile, unintentionally missed on the first round of implementation.
Fixes: https://mattermost.atlassian.net/browse/MM-31322
* Apply suggestions from code review
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
* linting issues
* Apply suggestions from code review
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
* revert showPermalink changes
* Revert "invert loadTeam.error test"
This reverts commit accf6c8fb7c56009a393a6e85084d4702deec9ed.
* support _redirect deeplinks
* Apply suggestions from code review
* Update app/components/post_list/index.js
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import client from './client';
|
|
import {getResponseFromError} from './common';
|
|
|
|
// ****************************************************************
|
|
// Preferences
|
|
// See https://api.mattermost.com/#tag/preferences
|
|
//
|
|
// Exported API function should have the following:
|
|
// - documented using JSDoc
|
|
// - meaningful description
|
|
// - match the referenced API endpoints
|
|
// - parameter/s defined by `@param`
|
|
// - return value defined by `@return`
|
|
// ****************************************************************
|
|
|
|
/**
|
|
* Save the user's preferences.
|
|
* @param {string} userId - the user ID
|
|
* @param {Array} preferences - a list of user's preferences
|
|
* @return {string} returns {status} on success or {error, status} on error
|
|
*/
|
|
export const apiSaveUserPreferences = async (userId, preferences = []) => {
|
|
try {
|
|
const response = await client.put(
|
|
`/api/v4/users/${userId}/preferences`,
|
|
preferences,
|
|
);
|
|
|
|
return {status: response.status};
|
|
} catch (err) {
|
|
return getResponseFromError(err);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Save the user's favorite channel preference.
|
|
* @param {string} userId - the user ID
|
|
* @param {string} channelId - the channel id to be favorited
|
|
* @return {string} returns {status} on success or {error, status} on error
|
|
*/
|
|
export const apiSaveFavoriteChannelPreference = (userId, channelId) => {
|
|
const preference = {
|
|
user_id: userId,
|
|
category: 'favorite_channel',
|
|
name: channelId,
|
|
value: 'true',
|
|
};
|
|
|
|
return apiSaveUserPreferences(userId, [preference]);
|
|
};
|
|
|
|
/**
|
|
* Save the user's teams order preference.
|
|
* @param {string} userId - the user ID
|
|
* @param {Array} orderedTeamIds - ordered array of team IDs
|
|
* @return {string} returns {status} on success or {error, status} on error
|
|
*/
|
|
export const apiSaveTeamsOrderPreference = (userId, orderedTeamIds = []) => {
|
|
const preference = {
|
|
user_id: userId,
|
|
category: 'teams_order',
|
|
name: '',
|
|
value: orderedTeamIds.toString(),
|
|
};
|
|
|
|
return apiSaveUserPreferences(userId, [preference]);
|
|
};
|
|
|
|
export const Preference = {
|
|
apiSaveUserPreferences,
|
|
apiSaveFavoriteChannelPreference,
|
|
apiSaveTeamsOrderPreference,
|
|
};
|
|
|
|
export default Preference;
|