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
16 changes: 8 additions & 8 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1350,47 +1350,47 @@ settings.addGroup('Push', function() {
this.section('Certificates_and_Keys', function() {
this.add('Push_apn_passphrase', '', {
type: 'string',
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_apn_key', '', {
type: 'string',
multiline: true,
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_apn_cert', '', {
type: 'string',
multiline: true,
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_apn_dev_passphrase', '', {
type: 'string',
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_apn_dev_key', '', {
type: 'string',
multiline: true,
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_apn_dev_cert', '', {
type: 'string',
multiline: true,
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
this.add('Push_gcm_api_key', '', {
type: 'string',
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
return this.add('Push_gcm_project_number', '', {
type: 'string',
public: true,
enableQuery: pushEnabledWithoutGateway,
enableQuery: [],
secret: true,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,7 @@
"Push_apn_passphrase": "APN Passphrase",
"Push_enable": "Enable",
"Push_enable_gateway": "Enable Gateway",
"Push_enable_gateway_Description": "You need to accept to register your server (Setup Wizard > Organization Info > Register Server) and our privacy terms (Setup Wizard > Cloud Info > Cloud Service Privacy Terms Agreement) to enabled this setting and use our gateway",
"Push_enable_gateway_Description": "<b>Warning:</b> You need to accept to register your server (Setup Wizard > Organization Info > Register Server) and our privacy terms (Setup Wizard > Cloud Info > Cloud Service Privacy Terms Agreement) to enabled this setting and use our gateway. Even if this setting is on it <b>won't</b> work if the server isn't registered.",
"Push_gateway": "Gateway",
"Push_gateway_description": "Multiple lines can be used to specify multiple gateways",
"Push_gcm_api_key": "GCM API Key",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,7 @@
"Push_apn_passphrase": "APN Passphrase",
"Push_enable": "Habilitar",
"Push_enable_gateway": "Ativar Gateway",
"Push_enable_gateway_Description": "<b>Atenção:</b> Para essa configuração funcionar é necessário registrar seu servidor (Assistente de configuração > Informação sobre a Organização > Registrar Servidor) e nossos termos de privacidade (Assistente de configuração > Cloud Info > Cloud Service Privacy Terms Agreement). Mesmo que essa opção esteja ligada o gateway <b>não</b> irá funcionar se o servidor não estiver registrado.",
"Push_gateway": "Gateway",
"Push_gcm_api_key": "Chave da API GCM",
"Push_gcm_project_number": "Número do Projeto GCM",
Expand Down
82 changes: 44 additions & 38 deletions server/lib/pushConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,51 +72,57 @@ Meteor.methods({
});

function configurePush() {
if (settings.get('Push_enable') === true) {
let apn;
let gcm;

if (settings.get('Push_enable_gateway') === false) {
gcm = {
apiKey: settings.get('Push_gcm_api_key'),
projectNumber: settings.get('Push_gcm_project_number'),
};
if (!settings.get('Push_enable')) {
return;
}

const gateways = settings.get('Push_enable_gateway') && settings.get('Register_Server') && settings.get('Cloud_Service_Agree_PrivacyTerms')
? settings.get('Push_gateway').split('\n')
: undefined;

let apn;
let gcm;

if (!gateways) {
gcm = {
apiKey: settings.get('Push_gcm_api_key'),
projectNumber: settings.get('Push_gcm_project_number'),
};

apn = {
passphrase: settings.get('Push_apn_passphrase'),
key: settings.get('Push_apn_key'),
cert: settings.get('Push_apn_cert'),
};

if (settings.get('Push_production') !== true) {
apn = {
passphrase: settings.get('Push_apn_passphrase'),
key: settings.get('Push_apn_key'),
cert: settings.get('Push_apn_cert'),
passphrase: settings.get('Push_apn_dev_passphrase'),
key: settings.get('Push_apn_dev_key'),
cert: settings.get('Push_apn_dev_cert'),
gateway: 'gateway.sandbox.push.apple.com',
};
}

if (settings.get('Push_production') !== true) {
apn = {
passphrase: settings.get('Push_apn_dev_passphrase'),
key: settings.get('Push_apn_dev_key'),
cert: settings.get('Push_apn_dev_cert'),
gateway: 'gateway.sandbox.push.apple.com',
};
}

if (!apn.key || apn.key.trim() === '' || !apn.cert || apn.cert.trim() === '') {
apn = undefined;
}

if (!gcm.apiKey || gcm.apiKey.trim() === '' || !gcm.projectNumber || gcm.projectNumber.trim() === '') {
gcm = undefined;
}
if (!apn.key || apn.key.trim() === '' || !apn.cert || apn.cert.trim() === '') {
apn = undefined;
}

Push.configure({
apn,
gcm,
production: settings.get('Push_production'),
gateways: settings.get('Push_enable_gateway') && settings.get('Register_Server') && settings.get('Cloud_Service_Agree_PrivacyTerms') ? settings.get('Push_gateway').split('\n') : undefined,
uniqueId: settings.get('uniqueID'),
getAuthorization() {
return `Bearer ${ getWorkspaceAccessToken() }`;
},
});
if (!gcm.apiKey || gcm.apiKey.trim() === '' || !gcm.projectNumber || gcm.projectNumber.trim() === '') {
gcm = undefined;
}
}

Push.configure({
apn,
gcm,
production: settings.get('Push_production'),
gateways,
uniqueId: settings.get('uniqueID'),
getAuthorization() {
return `Bearer ${ getWorkspaceAccessToken() }`;
},
});
}

Meteor.startup(configurePush);