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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@moodlehq/cordova-plugin-qrscanner": "3.0.1-moodle.5",
"@moodlehq/cordova-plugin-zip": "3.1.0-moodle.1",
"@moodlehq/ionic-native-push": "5.36.0-moodle.2",
"@moodlehq/phonegap-plugin-push": "4.0.0-moodle.3",
"@moodlehq/phonegap-plugin-push": "4.0.0-moodle.4",
"@ngx-translate/core": "13.0.0",
"@ngx-translate/http-loader": "6.0.0",
"@types/chart.js": "2.9.31",
Expand Down
1 change: 1 addition & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@
"core.settings.enablefirebaseanalyticsdescription": "local_moodlemobileapp",
"core.settings.enablerichtexteditor": "local_moodlemobileapp",
"core.settings.enablerichtexteditordescription": "local_moodlemobileapp",
"core.settings.encryptedpushsupported": "local_moodlemobileapp",
"core.settings.entriesincache": "local_moodlemobileapp",
"core.settings.estimatedfreespace": "local_moodlemobileapp",
"core.settings.filesystemroot": "local_moodlemobileapp",
Expand Down
17 changes: 15 additions & 2 deletions src/core/features/pushnotifications/services/pushnotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ export class CorePushNotificationsProvider {
try {

const data = this.getRequiredRegisterData();
data.publickey = await this.getPublicKey(site);
data.publickey = await this.getPublicKeyForSite(site);

const neededActions = await this.getRegisterDeviceActions(data, site, forceUnregister);

Expand Down Expand Up @@ -780,11 +780,24 @@ export class CorePushNotificationsProvider {
* @param site Site to register
* @returns Public key, undefined if the site or the device doesn't support encryption.
*/
protected async getPublicKey(site: CoreSite): Promise<string | undefined> {
protected async getPublicKeyForSite(site: CoreSite): Promise<string | undefined> {
if (!site.wsAvailable('core_user_update_user_device_public_key')) {
return;
}

return await this.getPublicKey();
}

/**
* Get the device public key.
*
* @returns Public key, undefined if the device doesn't support encryption.
*/
async getPublicKey(): Promise<string | undefined> {
if (!CorePlatform.isMobile()) {
return;
}

const publicKey = await Push.getPublicKey();

return publicKey ?? undefined;
Expand Down
1 change: 1 addition & 0 deletions src/core/features/settings/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"enablefirebaseanalyticsdescription": "If enabled, the app will collect anonymous data usage.",
"enablerichtexteditor": "Enable text editor",
"enablerichtexteditordescription": "If enabled, a text editor will be available when entering content.",
"encryptedpushsupported": "Encrypted push notifications supported",
"entriesincache": "{{$a}} entries in cache",
"estimatedfreespace": "Estimated free space",
"filesystemroot": "File system root",
Expand Down
7 changes: 7 additions & 0 deletions src/core/features/settings/pages/deviceinfo/deviceinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ <h1>
<p>{{ deviceInfo.pushId }}</p>
</ion-label>
</ion-item>
<ion-item *ngIf="deviceInfo.pushId" (longPress)="copyItemInfo($event)">
<ion-label class="ion-text-wrap">
<p class="item-heading">{{ 'core.settings.encryptedpushsupported' | translate }}</p>
<p *ngIf="!deviceInfo.encryptedPushSupported">{{ 'core.no' | translate }}</p>
<p *ngIf="deviceInfo.encryptedPushSupported">{{ 'core.yes' | translate }}</p>
</ion-label>
</ion-item>
<ion-item (longPress)="copyItemInfo($event)">
<ion-label class="ion-text-wrap">
<p class="item-heading">{{ 'core.settings.localnotifavailable' | translate }}</p>
Expand Down
6 changes: 6 additions & 0 deletions src/core/features/settings/pages/deviceinfo/deviceinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface CoreSettingsDeviceInfo {
uuid?: string;
pushId?: string;
localNotifAvailable: string;
encryptedPushSupported?: boolean;
}

/**
Expand Down Expand Up @@ -210,6 +211,11 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
const showDevOptionsOnConfig = await CoreConfig.get('showDevOptions', 0);
this.devOptionsForced = CoreConstants.BUILD.isDevelopment || CoreConstants.BUILD.isTesting;
this.showDevOptions = this.devOptionsForced || showDevOptionsOnConfig == 1;

const publicKey = this.deviceInfo.pushId ?
await CoreUtils.ignoreErrors(CorePushNotifications.getPublicKey()) :
undefined;
this.deviceInfo.encryptedPushSupported = publicKey !== undefined;
}

/**
Expand Down