mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-24 11:38:00 +01:00
[muc] Fix changeSubject() to throw XMPPErrorException on failures
When Smack requests a subject change of a MUC, an error returned by the server (eg: 'forbidden') should be propagated (as suggested by the pre-existing javadoc). Reported-by: Guus der Kinderen <guus@goodbytes.nl>
This commit is contained in:
parent
4ce926bd63
commit
147071ff64
1 changed files with 7 additions and 4 deletions
|
@ -2248,17 +2248,20 @@ public class MultiUserChat {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
MessageBuilder message = buildMessage();
|
||||
message.setSubject(subject);
|
||||
Message message = buildMessage()
|
||||
.setSubject(subject)
|
||||
.build();
|
||||
// Wait for an error or confirmation message back from the server.
|
||||
StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
|
||||
StanzaFilter successFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
Message msg = (Message) packet;
|
||||
return subject.equals(msg.getSubject());
|
||||
}
|
||||
});
|
||||
StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message.build());
|
||||
StanzaFilter errorFilter = new AndFilter(fromRoomFilter, new StanzaIdFilter(message), MessageTypeFilter.ERROR);
|
||||
StanzaFilter responseFilter = new OrFilter(successFilter, errorFilter);
|
||||
StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message);
|
||||
// Wait up to a certain number of seconds for a reply.
|
||||
response.nextResultOrThrow();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue