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

Team mention support #1966

Merged
merged 7 commits into from
Feb 13, 2025
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: 15 additions & 1 deletion NextcloudTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@
1F7AE07A29142E62009F72AD /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 1F7AE07929142E62009F72AD /* NextcloudKit */; };
1F7AE07C29142E6A009F72AD /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 1F7AE07B29142E6A009F72AD /* NextcloudKit */; };
1F7AE07D29158878009F72AD /* IntentsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F90EFC225FE489B00F3FA55 /* IntentsUI.framework */; };
1F7CCC242D552D2000F3FB77 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F7CCC232D552D2000F3FB77 /* Mention.swift */; };
1F7CCC252D552D2000F3FB77 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F7CCC232D552D2000F3FB77 /* Mention.swift */; };
1F7CCC262D552D2000F3FB77 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F7CCC232D552D2000F3FB77 /* Mention.swift */; };
1F7CCC272D552D2000F3FB77 /* Mention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F7CCC232D552D2000F3FB77 /* Mention.swift */; };
1F8848122A75B68D00063860 /* IntentsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F90EFC225FE489B00F3FA55 /* IntentsUI.framework */; };
1F8995B32970644C00CABA33 /* ColorGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8995B22970644C00CABA33 /* ColorGenerator.swift */; };
1F8995B52973547700CABA33 /* WebRTCCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8995B42973547700CABA33 /* WebRTCCommon.swift */; };
Expand Down Expand Up @@ -325,6 +329,7 @@
1FEDE3CE257D43AB00853F79 /* NCMessageFileParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FEDE3CC257D43AB00853F79 /* NCMessageFileParameter.m */; };
1FEDE3CF257D43AB00853F79 /* NCMessageFileParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FEDE3CC257D43AB00853F79 /* NCMessageFileParameter.m */; };
1FEDE3D0257D43AB00853F79 /* NCMessageFileParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FEDE3CC257D43AB00853F79 /* NCMessageFileParameter.m */; };
1FEF49B62D4D3C37001B400A /* UnitNCMessageParameterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FEF49B52D4D3C37001B400A /* UnitNCMessageParameterTest.swift */; };
1FF1360F2BFB4F8C006A6101 /* NCRoom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF1360E2BFB4F8C006A6101 /* NCRoom.swift */; };
1FF136102BFB4F8C006A6101 /* NCRoom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF1360E2BFB4F8C006A6101 /* NCRoom.swift */; };
1FF136112BFB4F8C006A6101 /* NCRoom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF1360E2BFB4F8C006A6101 /* NCRoom.swift */; };
Expand Down Expand Up @@ -787,6 +792,7 @@
1F785DDA2707865F00AC4B40 /* VoiceMessageTranscribeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VoiceMessageTranscribeViewController.m; sourceTree = "<group>"; };
1F785DDB2707865F00AC4B40 /* VoiceMessageTranscribeViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VoiceMessageTranscribeViewController.xib; sourceTree = "<group>"; };
1F785DDC2707865F00AC4B40 /* VoiceMessageTranscribeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoiceMessageTranscribeViewController.h; sourceTree = "<group>"; };
1F7CCC232D552D2000F3FB77 /* Mention.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mention.swift; sourceTree = "<group>"; };
1F8995B22970644C00CABA33 /* ColorGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorGenerator.swift; sourceTree = "<group>"; };
1F8995B42973547700CABA33 /* WebRTCCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebRTCCommon.swift; sourceTree = "<group>"; };
1F8AAC312C518759004DA20A /* SignalingSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignalingSettings.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -860,6 +866,7 @@
1FEDE3C5257D439500853F79 /* NCChatFileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCChatFileController.h; sourceTree = "<group>"; };
1FEDE3CC257D43AB00853F79 /* NCMessageFileParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCMessageFileParameter.m; sourceTree = "<group>"; };
1FEDE3CD257D43AB00853F79 /* NCMessageFileParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCMessageFileParameter.h; sourceTree = "<group>"; };
1FEF49B52D4D3C37001B400A /* UnitNCMessageParameterTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitNCMessageParameterTest.swift; sourceTree = "<group>"; };
1FF1360E2BFB4F8C006A6101 /* NCRoom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCRoom.swift; sourceTree = "<group>"; };
1FF136142BFB74C3006A6101 /* NCChatMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCChatMessage.swift; sourceTree = "<group>"; };
1FF2FD5B2AB99CCB000C9905 /* BroadcastUploadExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BroadcastUploadExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -1546,6 +1553,7 @@
1FBC3BE42B61ACD5003909E0 /* UnitBaseChatViewControllerTest.swift */,
1FB7B9842BE2EE020093CE98 /* UnitChatViewControllerTest.swift */,
1FF4DAA52C08D81D00C1B952 /* UnitNCChatMessageTest.swift */,
1FEF49B52D4D3C37001B400A /* UnitNCMessageParameterTest.swift */,
);
path = Chat;
sourceTree = "<group>";
Expand Down Expand Up @@ -2185,12 +2193,13 @@
1FAB2E842ACB482B001214EB /* ChatViewController.swift */,
1F35F8FA2AEEDBC600044BDA /* ChatViewControllerExtension.swift */,
2C4230F62B207AB00013E1FA /* ContextChatViewController.swift */,
1F0B0A712BA264540073FF8D /* MentionSuggestion.swift */,
F644A2DC2CE287FA00E2ED81 /* ChatFileUploader.swift */,
1F2058292CEA404F00AAA673 /* AiSummaryViewController.swift */,
1F20582B2CEA405700AAA673 /* AiSummaryViewController.xib */,
1F205B9F2CEE1B8800AAA673 /* AiSummaryController.swift */,
2C1C68062D51229500A7F98A /* CalendarEvent.swift */,
1F7CCC232D552D2000F3FB77 /* Mention.swift */,
1F0B0A712BA264540073FF8D /* MentionSuggestion.swift */,
);
name = Chat;
sourceTree = "<group>";
Expand Down Expand Up @@ -2827,6 +2836,7 @@
1F6D8C412B2F26D5004376B8 /* TestConstants.swift in Sources */,
1FB7B9872BE441450093CE98 /* UIViewExtensions.swift in Sources */,
1FBC3BE52B61ACD5003909E0 /* UnitBaseChatViewControllerTest.swift in Sources */,
1FEF49B62D4D3C37001B400A /* UnitNCMessageParameterTest.swift in Sources */,
1F8AAC622C596308004DA20A /* UnitSignalingSettings.swift in Sources */,
1F0B0A772BA26BE10073FF8D /* UnitMentionSuggestionTest.swift in Sources */,
1F6D8C432B2F26EE004376B8 /* Helpers.swift in Sources */,
Expand Down Expand Up @@ -2858,6 +2868,7 @@
1F77A5F42AB9A4B2007B6037 /* ABContact.m in Sources */,
1F77A6012AB9A51D007B6037 /* NCNotificationAction.swift in Sources */,
1FB7B9902BF0CDF80093CE98 /* BannedActor.swift in Sources */,
1F7CCC272D552D2000F3FB77 /* Mention.swift in Sources */,
1F77A5F32AB9A43B007B6037 /* SwiftMarkdownObjCBridge.swift in Sources */,
1FC4B3452CCE671800D28138 /* OcsError.swift in Sources */,
1FF4DA832C025DBF00C1B952 /* NCAPISessionManager.swift in Sources */,
Expand Down Expand Up @@ -3125,6 +3136,7 @@
1F35F9042AEEDF0E00044BDA /* AutoCompletionTableViewCell.m in Sources */,
2C42ADB420B58E6300296DEA /* NCChatController.m in Sources */,
1F20582A2CEA404F00AAA673 /* AiSummaryViewController.swift in Sources */,
1F7CCC242D552D2000F3FB77 /* Mention.swift in Sources */,
1FD9182928C55A73009092AB /* BGTaskHelper.swift in Sources */,
1F66B72929FA936E003FB168 /* SLKDefaultReplyView.m in Sources */,
1F785DDD2707865F00AC4B40 /* VoiceMessageTranscribeViewController.m in Sources */,
Expand Down Expand Up @@ -3202,6 +3214,7 @@
1F35F9052AEEDF0E00044BDA /* AutoCompletionTableViewCell.m in Sources */,
1F35F90A2AEEE76A00044BDA /* QuotedMessageView.m in Sources */,
2C62B02E24C1BDD7007E460A /* PlaceholderView.m in Sources */,
1F7CCC262D552D2000F3FB77 /* Mention.swift in Sources */,
2C62B01024C1BDC5007E460A /* NCRoom.m in Sources */,
1FDCC3ED29EC7E6700DEB39B /* AvatarImageView.swift in Sources */,
1F35F8E32AEEBBE000044BDA /* NCChatTitleView.m in Sources */,
Expand Down Expand Up @@ -3319,6 +3332,7 @@
2CC0016924A25C3400A20167 /* NCMessageParameter.m in Sources */,
1FB78E292B6AE8CA00B0D69D /* FederationInvitation.swift in Sources */,
2C444704265D641300DF1DBC /* NCUserDefaults.m in Sources */,
1F7CCC252D552D2000F3FB77 /* Mention.swift in Sources */,
1F205C512CEF91C500AAA673 /* UserAbsence.swift in Sources */,
2CC001B724A37A9A00A20167 /* NCUser.m in Sources */,
2CC0016124A25B5500A20167 /* NCAPIController.m in Sources */,
Expand Down
9 changes: 8 additions & 1 deletion NextcloudTalk/AvatarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import SDWebImage
return UIImage(named: "group-avatar", in: nil, compatibleWith: traitCollection)
}

public func getTeamAvatar(with style: UIUserInterfaceStyle) -> UIImage? {
let traitCollection = UITraitCollection(userInterfaceStyle: style)
return UIImage(named: "team-avatar", in: nil, compatibleWith: traitCollection)
}

public func getMailAvatar(with style: UIUserInterfaceStyle) -> UIImage? {
let traitCollection = UITraitCollection(userInterfaceStyle: style)
return UIImage(named: "mail-avatar", in: nil, compatibleWith: traitCollection)
Expand Down Expand Up @@ -86,8 +91,10 @@ import SDWebImage

if actorType == NCAttendeeTypeEmail || actorType == NCAttendeeTypeGuest {
image = self.getGuestsAvatar(withDisplayName: actorDisplayName ?? "", withStyle: style)
} else if actorType == NCAttendeeTypeGroup || actorType == NCAttendeeTypeCircle {
} else if actorType == NCAttendeeTypeGroup {
image = self.getGroupAvatar(with: style)
} else if actorType == NCAttendeeTypeCircle || actorType == NCAttendeeTypeTeams {
image = self.getTeamAvatar(with: style)
} else if actorType == "deleted_users" {
image = self.getDeletedUserAvatar()
} else {
Expand Down
43 changes: 4 additions & 39 deletions NextcloudTalk/BaseChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,6 @@ import SwiftUI
return unmanagedTemporaryMessage
}

internal func replaceMessageMentionsKeysWithMentionsDisplayNames(message: String, parameters: String) -> String {
var resultMessage = message.trimmingCharacters(in: .whitespacesAndNewlines)

guard let messageParametersDict = NCMessageParameter.messageParametersDict(fromJSONString: parameters) else { return resultMessage }

for (parameterKey, parameter) in messageParametersDict {
let parameterKeyString = "{\(parameterKey)}"
resultMessage = resultMessage.replacingOccurrences(of: parameterKeyString, with: parameter.mentionDisplayName)
}

return resultMessage
}

internal func appendTemporaryMessage(temporaryMessage: NCChatMessage) {
DispatchQueue.main.async {
let lastSectionBeforeUpdate = self.dateSections.count - 1
Expand Down Expand Up @@ -1017,9 +1004,10 @@ import SwiftUI
self.removeUnreadMessagesSeparator()

self.removePermanentlyTemporaryMessage(temporaryMessage: message)
guard var originalMessage = message.message else { return }

guard let originalMessage = message.sendingMessageWithDisplayNames else { return }

if message.messageType != kMessageTypeVoiceMessage {
originalMessage = self.replaceMessageMentionsKeysWithMentionsDisplayNames(message: message.message, parameters: message.messageParametersJSONString ?? "")
self.sendChatMessage(message: originalMessage, withParentMessage: message.parent, messageParameters: message.messageParametersJSONString ?? "", silently: message.isSilent)
} else {
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
Expand Down Expand Up @@ -1109,30 +1097,7 @@ import SwiftUI
// Show the message to edit in the reply view
self.showReplyView(for: message)
self.replyMessageView!.hideCloseButton()

self.mentionsDict = [:]

// Try to reconstruct the mentionsDict
for (key, value) in message.messageParameters {
if let key = key as? String,
key.hasPrefix("mention-"),
let value = value as? [String: String] {

guard let parameter = NCMessageParameter(dictionary: value),
let paramaterDisplayName = parameter.name,
let parameterId = parameter.parameterId
else { continue }

// For mentions the displayName is in the parameter "name", in our mentionsDict we use
// "mentionsDisplayName" for the displayName with the prefix "@", so we need to construct
// that manually here, so mentions are correctly removed while editing.
// The same needs to happen for "mentionId" -> userId with a prefixed "@"
parameter.mentionDisplayName = "@\(paramaterDisplayName)"
parameter.mentionId = "@\(parameterId)"
self.mentionsDict[key] = parameter
}
}

self.mentionsDict = message.mentionMessageParameters
self.editingMessage = message

// For files without a caption we start with an empty text instead of "{file}"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading