Skip to content

Commit

Permalink
[GH-61] Use SiteURL for all calls from the webapp (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: sanjay12345 <sanjaymj824@gmail.com>
Co-authored-by: Maisnam Raju Singh <85172229+maisnamrajusingh@users.noreply.github.com>
Co-authored-by: maisnamrajusingh <raju.s@demansol.com>
  • Loading branch information
4 people authored Mar 21, 2023
1 parent f2b297d commit f515bf4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
15 changes: 8 additions & 7 deletions webapp/src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ AuthenticationContext.prototype._loginPopup = function _loginPopup(urlNavigate,
};

export default class Client {
constructor() {
setServerRoute(url) {
this.url = `${url}/plugins/${pluginID}/api/v1`;
this.autodiscoverServiceUrl = 'https://webdir.online.lync.com/autodiscover/autodiscoverservice.svc/root';
this.registerMeetingFromOnlineVersionUrl = '/plugins/skype4business/api/v1/register_meeting_from_online_version';
this.clientIdUrl = '/plugins/skype4business/api/v1/client_id';
this.createMeetingInServerVersionUrl = '/plugins/skype4business/api/v1/create_meeting_in_server_version';
this.productTypeUrl = '/plugins/skype4business/api/v1/product_type';
this.authUrl = '/plugins/skype4business/api/v1/auth';
this.redirectUrl = '/plugins/skype4business/api/v1/auth_redirect';
this.registerMeetingFromOnlineVersionUrl = `${this.url}/register_meeting_from_online_version`;
this.clientIdUrl = `${this.url}/client_id`;
this.createMeetingInServerVersionUrl = `${this.url}/create_meeting_in_server_version`;
this.productTypeUrl = `${this.url}/product_type`;
this.authUrl = `${this.url}/auth`;
this.redirectUrl = `${this.url}/auth_redirect`;
}

createMeeting = async (channelId, currentUserId, getAuthenticationResult, personal = true, topic = '') => {
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import Icon from './components/icon.jsx';
import PostTypeS4b from './components/post_type_s4b';
import {startMeeting} from './actions';
import {handleAuthenticationResult} from './websocket';
import {getPluginServerRoute} from './selectors';
import Reducer from './reducers';
import Client from './client';

class Plugin {
// eslint-disable-next-line no-unused-vars
initialize(registry, store) {
registry.registerReducer(Reducer);
Client.setServerRoute(getPluginServerRoute(store.getState()));

const helpText = 'Start Skype for Business Meeting';
const action = (channel) => {
Expand Down
17 changes: 13 additions & 4 deletions webapp/src/selectors/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import {getConfig} from 'mattermost-redux/selectors/entities/general';

import {id as pluginId} from '../manifest';

const getPluginState = (state) => state['plugins-' + pluginId] || {};
const getPluginState = (state) => state[`plugins-${pluginId}`] || {};

export const getPluginServerRoute = (state) => {
const config = getConfig(state);

const getAuthenticationResult = (state) => getPluginState(state).authenticationResult;
let basePath = '';
if (config?.SiteURL) {
basePath = new URL(config.SiteURL).pathname;
basePath.replace(/\/$/, '');
}

export default {
getAuthenticationResult,
return basePath;
};

export const getAuthenticationResult = (state) => getPluginState(state).authenticationResult;

0 comments on commit f515bf4

Please sign in to comment.