Skip to content

Commit

Permalink
Fixed issue with sending PMs to MUC rooms with PMs disabled (if `muc#…
Browse files Browse the repository at this point in the history
…roomconfig_allowpm` was not reported in room disco#info) #132
  • Loading branch information
hantu85 committed Jul 19, 2023
1 parent c45b790 commit f03a844
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
14 changes: 11 additions & 3 deletions BeagleIM/channel/EnterChannelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,18 @@ class EnterChannelViewController: NSViewController, NSTextFieldDelegate {
switch roomResult {
case .created(let room), .joined(let room):
(room as! Room).roomFeatures = Set(features.compactMap({ Room.Feature(rawValue: $0) }));
if let formElement = formElement, let config = RoomConfig(element: formElement) {
(room as! Room).allowedPM = config.allowPM ?? .anyone;
if let formElement = formElement, let config = RoomConfig(element: formElement), let allowPM = config.allowPM {
(room as! Room).allowedPM = allowPM;
} else {
(room as! Room).allowedPM = .anyone;
(room as! Room).allowedPM = .none;
client.module(.muc).roomConfiguration(roomJid: JID(room.jid), completionHandler: { result in
switch result {
case .success(let config):
(room as! Room).allowedPM = config.allowPM ?? .none;
case .failure(let err):
(room as! Room).allowedPM = .none;
}
})
}
}
if createBookmark {
Expand Down
2 changes: 1 addition & 1 deletion BeagleIM/database/model/conversations/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class Chat: ConversationBaseWithOptions<ChatOptions>, ChatProtocol, Conve
}

public func prepareAttachment(url originalURL: URL, completionHandler: @escaping (Result<(URL, Bool, ((URL) -> URL)?), ShareError>) -> Void) {
let encryption = self.options.encryption ?? .none;
let encryption = self.options.encryption ?? Settings.messageEncryption;
switch encryption {
case .none:
completionHandler(.success((originalURL, false, nil)));
Expand Down
14 changes: 13 additions & 1 deletion BeagleIM/service/MucEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,19 @@ class MucEventHandler: XmppServiceExtension {
mamVersions = info.features.compactMap({ MessageArchiveManagementModule.Version(rawValue: $0) });
(room as! Room).roomFeatures = Set(info.features.compactMap({ Room.Feature(rawValue: $0) }));
let config = RoomConfig(form: info.form);
(room as! Room).allowedPM = config.allowPM ?? .anyone;
if let allowPM = config.allowPM {
(room as! Room).allowedPM = allowPM;
} else {
(room as! Room).allowedPM = .none;
client.module(.muc).roomConfiguration(roomJid: JID(room.jid), completionHandler: { result in
switch result {
case .success(let config):
(room as! Room).allowedPM = config.allowPM ?? .none;
case .failure(let err):
(room as! Room).allowedPM = .none;
}
})
}
default:
break;
}
Expand Down

0 comments on commit f03a844

Please sign in to comment.