Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default {
Accounts_ManuallyApproveNewUsers: {
type: 'valueAsBoolean'
},
API_Use_REST_For_DDP_Calls: {
type: 'valueAsBoolean'
},
Accounts_iframe_enabled: {
type: 'valueAsBoolean'
},
Expand Down
2 changes: 1 addition & 1 deletion app/lib/methods/callJitsi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function callJitsi(rid, onlyAudio = false) {

if (Jitsi_Enabled_TokenAuth) {
try {
accessToken = await this.sdk.methodCall('jitsi:generateAccessToken', rid);
accessToken = await this.methodCallWrapper('jitsi:generateAccessToken', rid);
} catch (e) {
// do nothing
}
Expand Down
77 changes: 42 additions & 35 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const RocketChat = {
name, users, type, readOnly, broadcast
}) {
// RC 0.51.0
return this.methodCall(type ? 'createPrivateGroup' : 'createChannel', name, users, readOnly, {}, { broadcast });
return this.methodCallWrapper(type ? 'createPrivateGroup' : 'createChannel', name, users, readOnly, {}, { broadcast });
},
async getUserToken() {
try {
Expand Down Expand Up @@ -318,20 +318,16 @@ const RocketChat = {
reduxStore.dispatch(shareSetUser({}));
},

updateJitsiTimeout(rid) {
return this.methodCall('jitsi:updateTimeout', rid);
updateJitsiTimeout(roomId) {
// RC 0.74.0
return this.post('jitsi.updateTimeout', { roomId });
},

register(credentials) {
// RC 0.50.0
return this.post('users.register', credentials, false);
},

setUsername(username) {
// RC 0.51.0
return this.methodCall('setUsername', username);
},

forgotPassword(email) {
// RC 0.64.0
return this.post('users.forgotPassword', { email }, false);
Expand Down Expand Up @@ -567,7 +563,7 @@ const RocketChat = {

spotlight(search, usernames, type) {
// RC 0.51.0
return this.methodCall('spotlight', search, usernames, type);
return this.methodCallWrapper('spotlight', search, usernames, type);
},

createDirectMessage(username) {
Expand Down Expand Up @@ -596,7 +592,7 @@ const RocketChat = {
// TODO: join code
// RC 0.48.0
if (type === 'p') {
return this.methodCall('joinRoom', roomId);
return this.methodCallWrapper('joinRoom', roomId);
}
return this.post('channels.join', { roomId });
},
Expand Down Expand Up @@ -738,11 +734,22 @@ const RocketChat = {
},
getRoomMembers(rid, allUsers, skip = 0, limit = 10) {
// RC 0.42.0
return this.methodCall('getUsersOfRoom', rid, allUsers, { skip, limit });
return this.methodCallWrapper('getUsersOfRoom', rid, allUsers, { skip, limit });
},

async methodCallWrapper(method, ...params) {
const { API_Use_REST_For_DDP_Calls } = reduxStore.getState().settings;
if (API_Use_REST_For_DDP_Calls) {
const data = await this.post(`method.call/${ method }`, { message: JSON.stringify({ method, params }) });
const { result } = JSON.parse(data.message);
return result;
}
return this.methodCall(method, ...params);
},

getUserRoles() {
// RC 0.27.0
return this.methodCall('getUserRoles');
return this.methodCallWrapper('getUserRoles');
},
getRoomCounters(roomId, t) {
// RC 0.65.0
Expand All @@ -767,19 +774,19 @@ const RocketChat = {
},
closeLivechat(rid, comment) {
// RC 0.29.0
return this.methodCall('livechat:closeRoom', rid, comment, { clientAction: true });
return this.methodCallWrapper('livechat:closeRoom', rid, comment, { clientAction: true });
},
editLivechat(userData, roomData) {
// RC 0.55.0
return this.methodCall('livechat:saveInfo', userData, roomData);
return this.methodCallWrapper('livechat:saveInfo', userData, roomData);
},
returnLivechat(rid) {
// RC 0.72.0
return this.methodCall('livechat:returnAsInquiry', rid);
return this.methodCallWrapper('livechat:returnAsInquiry', rid);
},
forwardLivechat(transferData) {
// RC 0.36.0
return this.methodCall('livechat:transfer', transferData);
return this.methodCallWrapper('livechat:transfer', transferData);
},
getPagesLivechat(rid, offset) {
// RC 2.3.0
Expand All @@ -799,11 +806,11 @@ const RocketChat = {
},
getRoutingConfig() {
// RC 2.0.0
return this.methodCall('livechat:getRoutingConfig');
return this.methodCallWrapper('livechat:getRoutingConfig');
},
getTagsList() {
// RC 2.0.0
return this.methodCall('livechat:getTagsList');
return this.methodCallWrapper('livechat:getTagsList');
},
getAgentDepartments(uid) {
// RC 2.4.0
Expand All @@ -815,7 +822,7 @@ const RocketChat = {
},
changeLivechatStatus() {
// RC 0.26.0
return this.methodCall('livechat:changeLivechatStatus');
return this.methodCallWrapper('livechat:changeLivechatStatus');
},

getUidDirectMessage(room) {
Expand Down Expand Up @@ -843,10 +850,10 @@ const RocketChat = {
toggleBlockUser(rid, blocked, block) {
if (block) {
// RC 0.49.0
return this.methodCall('blockUser', { rid, blocked });
return this.methodCallWrapper('blockUser', { rid, blocked });
}
// RC 0.49.0
return this.methodCall('unblockUser', { rid, blocked });
return this.methodCallWrapper('unblockUser', { rid, blocked });
},
leaveRoom(roomId, t) {
// RC 0.48.0
Expand All @@ -859,10 +866,10 @@ const RocketChat = {
toggleMuteUserInRoom(rid, username, mute) {
if (mute) {
// RC 0.51.0
return this.methodCall('muteUserInRoom', { rid, username });
return this.methodCallWrapper('muteUserInRoom', { rid, username });
}
// RC 0.51.0
return this.methodCall('unmuteUserInRoom', { rid, username });
return this.methodCallWrapper('unmuteUserInRoom', { rid, username });
},
toggleArchiveRoom(roomId, t, archive) {
if (archive) {
Expand All @@ -877,7 +884,7 @@ const RocketChat = {
},
saveRoomSettings(rid, params) {
// RC 0.55.0
return this.methodCall('saveRoomSettings', rid, params);
return this.methodCallWrapper('saveRoomSettings', rid, params);
},
post(...args) {
return new Promise(async(resolve, reject) => {
Expand Down Expand Up @@ -930,9 +937,9 @@ const RocketChat = {
// RC 0.62.2
return this.post('users.updateOwnBasicInfo', { data, customFields });
},
saveUserPreferences(params) {
// RC 0.51.0
return this.methodCall('saveUserPreferences', params);
saveUserPreferences(data) {
// RC 0.62.0
return this.post('users.setPreferences', { data });
},
saveNotificationSettings(roomId, notifications) {
// RC 0.63.0
Expand All @@ -942,11 +949,11 @@ const RocketChat = {
let { users } = reduxStore.getState().selectedUsers;
users = users.map(u => u.name);
// RC 0.51.0
return this.methodCall('addUsersToRoom', { rid, users });
return this.methodCallWrapper('addUsersToRoom', { rid, users });
},
getSingleMessage(msgId) {
// RC 0.57.0
return this.methodCall('getSingleMessage', msgId);
// RC 0.47.0
return this.sdk.get('chat.getMessage', { msgId });
},
async hasPermission(permissions, rid) {
const db = database.active;
Expand Down Expand Up @@ -991,15 +998,15 @@ const RocketChat = {
},
getAvatarSuggestion() {
// RC 0.51.0
return this.methodCall('getAvatarSuggestion');
return this.methodCallWrapper('getAvatarSuggestion');
},
resetAvatar(userId) {
// RC 0.55.0
return this.post('users.resetAvatar', { userId });
},
setAvatarFromService({ data, contentType = '', service = null }) {
// RC 0.51.0
return this.methodCall('setAvatarFromService', data, contentType, service);
return this.methodCallWrapper('setAvatarFromService', data, contentType, service);
},
async getAllowCrashReport() {
const allowCrashReport = await AsyncStorage.getItem(CRASH_REPORT_KEY);
Expand Down Expand Up @@ -1211,13 +1218,13 @@ const RocketChat = {
saveAutoTranslate({
rid, field, value, options
}) {
return this.methodCall('autoTranslate.saveSettings', rid, field, value, options);
return this.methodCallWrapper('autoTranslate.saveSettings', rid, field, value, options);
},
getSupportedLanguagesAutoTranslate() {
return this.methodCall('autoTranslate.getSupportedLanguages', 'en');
return this.methodCallWrapper('autoTranslate.getSupportedLanguages', 'en');
},
translateMessage(message, targetLanguage) {
return this.methodCall('autoTranslate.translateMessage', message, targetLanguage);
return this.methodCallWrapper('autoTranslate.translateMessage', message, targetLanguage);
},
getRoomTitle(room) {
const { UI_Use_Real_Name: useRealName, UI_Allow_room_names_with_special_chars: allowSpecialChars } = reduxStore.getState().settings;
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class RoomView extends React.Component {
});
});
} else {
const thread = await RocketChat.getSingleMessage(tmid);
const { message: thread } = await RocketChat.getSingleMessage(tmid);
await db.action(async() => {
await db.batch(
threadCollection.prepareCreate((t) => {
Expand Down
2 changes: 1 addition & 1 deletion app/views/SetUsernameView.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SetUsernameView extends React.Component {

this.setState({ saving: true });
try {
await RocketChat.setUsername(username);
await RocketChat.saveUserProfile({ username });
await loginRequest({ resume: token });
} catch (e) {
showErrorAlert(e.message, I18n.t('Oops'));
Expand Down