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

refactor: process conversation rename event - WPB-10177 #2175

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

jullianm
Copy link
Contributor

@jullianm jullianm commented Nov 20, 2024

WPB-10177

Key points

This PR is part of the quick sync refactoring plan and is related to processing the multiple events we receive from the backend or the push channel.

Specifically, this PR is about porting the existing implementation of the ConversationRename event.

In addition:

  • Redundant message creation code was removed from the ConversationRepository now that we have a dedicated MessageRepository
  • Implementation had to be consequently a bit revisited so we can make use of the MessageRepository where we need to.
  • No longer necessary code was removed

Testing

  • Testing dedicated conversation repository method is correctly invoked by the processor
  • Testing conversation name is correctly updated
  • Add use cases tests for message creation
  • Fix existing tests

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

LGTM, minor suggestions

message,
to: conversation
var systemMessageType: MessageType = switch reason {
case .userDeleted, .left:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case .userDeleted, .left:
case .userDeleted, .userLeft:

member: (senderID, senderDomain),
date: date
)
case .removed:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case .removed:
case .userRemoved:

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice work!

)

guard let localConversation else {
return WireLogger.eventProcessing.error(
Copy link
Contributor

@samwyndham samwyndham Nov 22, 2024

Choose a reason for hiding this comment

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

Personally I find this pattern (returning void by calling something that returns void) super confusing. If I look at WireLogger.eventProcessing.error without knowing about our WireLogger I assume we are actually throwing an error then see that there is no throw. Is this a common pattern? I've only seen it at Wire.

to conversation: ZMConversation
func updateConversationName(
newName: String,
conversationID: UUID,
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: We do have a lot of ID (UUID), domain (String?) pairs. They are almost a QualifiedID but not quite. I wonder if there is an improvement we can make here to save some boilerplate.

I also wonder if it is worth representing a conversation id+domain differently from a sender id+domain to prevent accidentally passing incorrect values.

I would consider introducing the following kinds of types:

struct ConversationID {
    id: UUID
    domain: String?
}

) async -> Set<ZMUser> {
await withTaskGroup(of: ZMUser.self) { taskGroup in
for userID in userIDs {
taskGroup.addTask { [self] in
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a request for change but just a thought:

I think there is probably unnecessary overhead with awaiting, locking in core data etc here. To avoid this we I think we should have a UserLocalStore.fetchOrCreateUsers(userIDs: [(id: UUID, domain: String?)]) -> [ZMUser] and have everything done within a single perform.

When wrapping core data it is probably more performant that our methods accept arrays of values I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: technical-roadmap/technical-debt Changes intended at mitigating risks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants