Skip to content

Commit

Permalink
Remove "displayName" field from group messages
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Pex committed Nov 14, 2017
1 parent 7b7e15b commit 7895515
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 0 additions & 7 deletions ChatSecure/Classes/Controllers/XMPP/OTRXMPPRoomYapStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ - (void)insertIncomingMessage:(XMPPMessage *)message intoRoom:(XMPPRoom *)room
databaseMessage.roomJID = databaseRoom.jid;
databaseMessage.state = RoomMessageStateReceived;
databaseMessage.roomUniqueId = databaseRoom.uniqueId;
XMPPJID *roomJID = [XMPPJID jidWithString:databaseMessage.roomJID];
if (!roomJID) { return; }
OTRXMPPRoomOccupant *occupant = [OTRXMPPRoomOccupant occupantWithJid:fromJID realJID:nil roomJID:roomJID accountId:accountId createIfNeeded:YES transaction:transaction];
databaseMessage.displayName = occupant.realJID;
if (!databaseMessage.displayName) {
databaseMessage.displayName = [fromJID full];
}

databaseRoom.lastRoomMessageId = [databaseMessage uniqueId];
NSString *activeThreadYapKey = [[OTRAppDelegate appDelegate] activeThreadYapKey];
Expand Down
8 changes: 4 additions & 4 deletions ChatSecure/Classes/Model/Yap Storage/OTRXMPPRoomMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ open class OTRXMPPRoomMessage: OTRYapDatabaseObject {
@objc open var roomJID:String?
/** This is the full JID of the sender. This should be equal to the occupant.jid*/
@objc open var senderJID:String?
@objc open var displayName:String?
@objc open var state:RoomMessageState = .received
@objc open var deliveredDate = Date.distantPast
@objc open var messageText:String?
Expand Down Expand Up @@ -73,7 +72,6 @@ extension OTRXMPPRoomMessage:OTRMessageProtocol {
newMessage.roomUniqueId = self.roomUniqueId
newMessage.roomJID = self.roomJID
newMessage.senderJID = self.senderJID
newMessage.displayName = self.displayName
newMessage.messageSecurity = self.messageSecurity
newMessage.state = .needsSending
newMessage.xmppId = UUID().uuidString
Expand Down Expand Up @@ -176,7 +174,6 @@ public class OTRGroupDownloadMessage: OTRXMPPRoomMessage, OTRDownloadMessage {
download.roomUniqueId = parentMessage.threadId
if let groupMessage = parentMessage as? OTRXMPPRoomMessage {
download.senderJID = groupMessage.senderJID
download.displayName = groupMessage.displayName
download.roomJID = groupMessage.roomJID
}
return download
Expand Down Expand Up @@ -317,7 +314,10 @@ extension OTRXMPPRoomMessage:JSQMessageData {
}

public func senderDisplayName() -> String! {
return self.displayName ?? ""
if let sender = self.senderJID, let jid = XMPPJID(string: sender), let resource = jid.resource {
return resource
}
return self.senderJID ?? ""
}

public func date() -> Date {
Expand Down

0 comments on commit 7895515

Please sign in to comment.