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

Identity server & Contact Integration #280

Open
wants to merge 12 commits into
base: stable
Choose a base branch
from
Open

Conversation

stefanhofman
Copy link
Member

Enables the option to enable Identity Servers and Contact Synchronization to start new chats based on email, phone number, or by simple pressing a contact that is using Matrix.

Copy link
Member

@kiliankoe kiliankoe left a comment

Choose a reason for hiding this comment

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

This is extremely cool! I love it!

I left some minor comments with some feedback inline, but all in all it looks great.

Nio/NewConversation/NewConversationView.swift Outdated Show resolved Hide resolved
struct NewConversationContainerView: View {
@EnvironmentObject private var store: AccountStore
@Binding var createdRoomId: ObjectIdentifier?
@AppStorage("matrixUsers") private var matrixUsersJSON: String = ""
Copy link
Member

Choose a reason for hiding this comment

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

This probably works nicely for now, but I'm unsure about storing this in user defaults in the long term. Not sure where the limits are. Any thoughts @pixlwave, @helje5?

Would it somehow be possible to query this directly from the Contacts framework here? I really don't know, just a thought.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is just for persisting the last selection I think? That would be kinda OK. The bigger issue is that this is not scoped on the scene. I.e. if you have multiple scenes open (on iPad or windows on macOS) and you'd want to join different conversations, they would all show the same set. I think what you'd want here is a State which is initialised from a user default.

My general recommendation: One StateObject per scene, and from there drill down into distinct detail observed objects, e.g. one representing a new conversation in this case. But that would be a bigger refactoring.

Not sure what the Contacts.fw has to do with this.

Copy link
Member

@kiliankoe kiliankoe Mar 26, 2021

Choose a reason for hiding this comment

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

As far as I can tell from the context this is a list of contacts matched with the identity server to have a linked Matrix account, serialized to JSON and stored in user defaults. But it's totally possible I read this wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looks like persistence of matched users to me. Re limits: last time I hit a limit in user defaults it was "4194304 bytes of data"

Copy link
Member

Choose a reason for hiding this comment

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

Not that I'd necessarily push for storing this in CoreData, which would just open ten new cans of worms, but maybe this would better be stored as a json file on disk? Or would that be too error-prone?

Copy link
Member

Choose a reason for hiding this comment

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

Another option would be storing this in it's own suite that's separate from settings:

@AppStorage("matrixUsers", store: UserDefaults.contacts) private var matrixUsersJSON: String = ""

Maybe this could actually be the group suite which is already about storing Matrix state? Not sure re any privacy implications of that though 🕵️.

Also, a nice tidy up would be to conform codable arrays to RawRepresentable like this and then you could have:

@AppStorage("matrixUsers", store: UserDefaults.contacts) private var matrixUsers: [MatrixUser] = []

Copy link
Member Author

Choose a reason for hiding this comment

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

Something else we might be able to do is use the “instant message” field in contacts. I will have to find out how that works, but that would remove the need for us to store it ourselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm using the messaging fields in Past for iChat to find user thumbnails and names. (It is an app-wide ObservedObject, I guess I could post the code).
And yes, ideally you'd use that to link and store the Matrix address, i.e. like Mail.app does.

It's too long ago, but Contacts is essentially using the vCard model. IIRC the IMPP field can have a type and those fields can also all have a "label". The "label" is for things like "Home", "Friends" or "Work" (i.e. like a tag). We might be able to use a custom type for Matrix, I'm not entirely sure about that, but it probably works.

Nio/NewConversation/NewConversationView.swift Outdated Show resolved Hide resolved
Nio/NewConversation/NewConversationView.swift Outdated Show resolved Hide resolved
Nio/NewConversation/NewConversationView.swift Outdated Show resolved Hide resolved
Nio/Settings/IdentityServerSettings.swift Show resolved Hide resolved
Nio/Supporting Files/en.lproj/Localizable.strings Outdated Show resolved Hide resolved
Nio/Supporting Files/en.lproj/Localizable.strings Outdated Show resolved Hide resolved
NioKit/Extensions/Contacts.swift Outdated Show resolved Hide resolved
@AppStorage("identityServer") private var identityServer: String = "https://vector.im"
@AppStorage("identityServerBool") private var identityServerBool: Bool = false
@AppStorage("matrixUsers") private var matrixUsersJSON: String = ""
@AppStorage("locSyncContacts") private var locSyncContacts: Bool = false
Copy link
Member

Choose a reason for hiding this comment

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

Is this a typo? What does loc stand for?

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.

4 participants