Chore: Server API types - user.setPreferences (#3781)
* chore: implementing type for test api - user.setPreferences * chore: minor tweak
This commit is contained in:
parent
4ba7f16b71
commit
7de686b0e8
|
@ -103,6 +103,22 @@ export interface IUserSettings {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
type TNotifications = 'default' | 'all' | 'mentions' | 'nothing';
|
||||||
|
|
||||||
|
export interface INotificationPreferences {
|
||||||
|
id: string;
|
||||||
|
enableMessageParserEarlyAdoption: boolean;
|
||||||
|
desktopNotifications: TNotifications;
|
||||||
|
pushNotifications: TNotifications;
|
||||||
|
emailNotificationMode?: 'mentions' | 'nothing';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IUserPreferences {
|
||||||
|
user: { _id: string };
|
||||||
|
settings: {
|
||||||
|
preferences: INotificationPreferences;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface IUser extends IRocketChatRecord, Omit<ILoggedUser, 'username' | 'name' | 'status'> {
|
export interface IUser extends IRocketChatRecord, Omit<ILoggedUser, 'username' | 'name' | 'status'> {
|
||||||
_id: string;
|
_id: string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IUser, IUserRegistered } from '../../IUser';
|
import { INotificationPreferences, IUser, IUserPreferences, IUserRegistered } from '../../IUser';
|
||||||
|
|
||||||
export type UserEndpoints = {
|
export type UserEndpoints = {
|
||||||
'users.info': {
|
'users.info': {
|
||||||
|
@ -11,6 +11,12 @@ export type UserEndpoints = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
'users.setPreferences': {
|
||||||
|
POST: (params: { userId: IUser['_id']; data: Partial<INotificationPreferences> }) => {
|
||||||
|
user: IUserPreferences;
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
'users.register': {
|
'users.register': {
|
||||||
POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered };
|
POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered };
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { SubscriptionType } from '../../../definitions';
|
import sdk from './sdk';
|
||||||
import { TEAM_TYPE } from '../../../definitions/ITeam';
|
import { TEAM_TYPE } from '../../../definitions/ITeam';
|
||||||
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
|
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
|
||||||
import sdk from './sdk';
|
import { SubscriptionType, INotificationPreferences } from '../../../definitions';
|
||||||
|
|
||||||
export const createChannel = ({
|
export const createChannel = ({
|
||||||
name,
|
name,
|
||||||
|
@ -283,10 +283,8 @@ export const reportMessage = (messageId: string): any =>
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sdk.post('chat.reportMessage', { messageId, description: 'Message reported by user' });
|
sdk.post('chat.reportMessage', { messageId, description: 'Message reported by user' });
|
||||||
|
|
||||||
export const setUserPreferences = (userId: string, data: any): any =>
|
export const setUserPreferences = (userId: string, data: Partial<INotificationPreferences>) =>
|
||||||
// RC 0.62.0
|
// RC 0.62.0
|
||||||
// TODO: missing definitions from server
|
|
||||||
// @ts-ignore
|
|
||||||
sdk.post('users.setPreferences', { userId, data });
|
sdk.post('users.setPreferences', { userId, data });
|
||||||
|
|
||||||
export const setUserStatus = (status?: string, message?: string): any =>
|
export const setUserStatus = (status?: string, message?: string): any =>
|
||||||
|
|
|
@ -106,10 +106,12 @@ class UserNotificationPreferencesView extends React.Component<
|
||||||
const { user } = this.props;
|
const { user } = this.props;
|
||||||
const { id } = user;
|
const { id } = user;
|
||||||
const result = await RocketChat.setUserPreferences(id, params);
|
const result = await RocketChat.setUserPreferences(id, params);
|
||||||
|
if (result.success) {
|
||||||
const {
|
const {
|
||||||
user: { settings }
|
user: { settings }
|
||||||
} = result;
|
} = result;
|
||||||
this.setState({ preferences: settings.preferences });
|
this.setState({ preferences: settings.preferences });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Reference in New Issue