Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended notification preview #6927

Merged
merged 6 commits into from
May 22, 2024
Merged

Extended notification preview #6927

merged 6 commits into from
May 22, 2024

Conversation

charlag
Copy link
Contributor

@charlag charlag commented May 10, 2024

Implemented extended notifications which include the sender.

Re-implemented credential encryption and storage, moved credential data to the native storage, changed credential encryption on mobile to always be device lock + implement app lock independently of encryption.

Re-implemented SSE on desktop in a more modular way.

Re-organized iOS app to share the code between the main app code and app extensions.

Close #6608

tutadb!614


Test notes

Everything needs to be tested on all three platforms:

  • Desktop
  • Android
  • iOS

  • Extended notification options
    • A new section notification with notification content and Push Identifier
    • For new logins, set to ONLY_SENDER
    • For existing logins, NO_SENDER_OR_SUBJECT
  • Extended notification
    • When set to NO_SENDER_OR_SUBJECT, notification title is New email received and body is recipient address
    • For other options, notification title is sender's address and body is recipient address
  • App lock method
    • On desktop, has two options Automatic unlock and App password
    • On mobile, has three options Automatic unlock, System password or biometrics and Biometrics
  • App lock
    • On desktop, app password works as before
    • On mobile, if set to System password or biometrics or Biometrics, password or biometrics needs to be verified before login and unlock
  • Migration
    • Credentials still work after updating from an old version
  • Desktop notifications (regression). Use terminal output as help.
    • It reconnects after connection was broken
    • It tries to reconnect with increased time interval when it fails
    • It connects after logging in with a new account
    • It stops reconnecting when there are no valid logins to connect with
  • Alarms still are received and are scheduled/unscheduled
  • Sharing on iOS still works

@charlag charlag force-pushed the notification-preview-6608-4 branch from d84951d to 7e1bdcf Compare May 10, 2024 14:36
app-android/app/build.gradle Outdated Show resolved Hide resolved
private val authenticationPrompt: AuthenticationPrompt,
) : NativeCredentialsFacade {
private val keyStoreFacade: AndroidKeyStoreFacade,
private val activity: Context,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to Context? It still being used as a FragmentActivity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is also used from a JobService alongside the MainActivity. The as FragmentActivity ones are not called from the service. We can maybe refactor this later, for now it needs to use Context to match both.

if (encryptionMode == CredentialEncryptionMode.BIOMETRICS) {
promptInfoBuilder.setNegativeButtonText(activity.getString(android.R.string.cancel))
}
val promptInfo = promptInfoBuilder.build()
authenticationPrompt.authenticateCryptoObject(activity, promptInfo, cryptoObject)
authenticationPrompt.authenticateCryptoObject(activity as FragmentActivity, promptInfo, cryptoObject)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines 26 to 29
if (login != other.login) return false
if (type != other.type) return false
if (userId != other.userId) return false
if (encryptedPassword != other.encryptedPassword) return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be better to merge these four if statements in just one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +41 to +45
result = 31 * result + type.hashCode()
result = 31 * result + userId.hashCode()
result = 31 * result + encryptedPassword.hashCode()
result = 31 * result + (databaseKey?.contentHashCode() ?: 0)
result = 31 * result + accessToken.contentHashCode()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason, other than the standard hashCode implementation, for using 31?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it comes from server code. Need to ask @charlag exactly why though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what IDEA is generating. We need impl here because we have by arrays

Comment on lines +57 to +58
public func deleteByUserId(_ id: String) async throws { try self.credentialsDb.delete(userId: id) }
public func getCredentialEncryptionMode() async throws -> CredentialEncryptionMode? { try self.credentialsDb.getCredentialEncryptionMode() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

func getExtendedNotificationConfig(_ userId: String) async throws -> TutanotaSharedFramework.ExtendedNotificationMode {
try self.notificationStorage.getExtendedNotificationConfig(userId)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async without await

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines 31 to 34
let systemPasswordSupported = self.appLockHandler.isSystemPasswordSupported()
if systemPasswordSupported { supportedMethods.append(.system_pass_or_biometrics) }
let biometricsSupported = self.appLockHandler.isBiometricsSupported()
if biometricsSupported { supportedMethods.append(.biometrics) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be simplified to if let ... =?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

) {}

async onMailNotification(sseInfo: SseInfo, notificationInfo: NotificationInfo) {
const w = this.wm.getAll().find((w) => w.getUserId() === notificationInfo.userId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a better name instead of just w and wm. Maybe mainWindow and winManager?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines 2 to 3
internal = "internal",
external = "external",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use PascalCase or UPPER_SNAKE_CASE as they seem to be our standard

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

charlag and others added 3 commits May 22, 2024 14:27
Implemented extended notifications which include the sender.

Re-implemented credential encryption and storage, moved credential
data to the native storage, changed credential encryption on mobile to
always be device lock + implement app lock independently of encryption.

Re-implemented SSE on desktop in a more modular way.

Re-organized iOS app to share the code between the main app code and
app extensions.

Close #6608

Co-authored-by: wec43 <wec@tutao.de>
@wec43 wec43 force-pushed the notification-preview-6608-4 branch 2 times, most recently from c2002f5 to d3774c6 Compare May 22, 2024 12:31
@wec43 wec43 force-pushed the notification-preview-6608-4 branch from d3774c6 to 7fac9d9 Compare May 22, 2024 12:51
@wec43 wec43 force-pushed the notification-preview-6608-4 branch from 8bb19f9 to 16daa99 Compare May 22, 2024 13:27
@wrdhub wrdhub force-pushed the notification-preview-6608-4 branch from 46b2bf6 to 1dba6e9 Compare May 22, 2024 14:02
@wrdhub wrdhub added this pull request to the merge queue May 22, 2024
Merged via the queue into master with commit 0b5aac8 May 22, 2024
2 checks passed
@wrdhub wrdhub deleted the notification-preview-6608-4 branch May 22, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview in email notification: sender & recipient
4 participants