[Telepathy-commits] [telepathy-gabble/master] Fix auto-accepting MUC invites when changing presence
Robert McQueen
robert.mcqueen at collabora.co.uk
Mon Dec 8 07:38:05 PST 2008
The patch to send our presence to the MUC when we go away/etc was broken
because it sent a <presence> stanza to MUC channels we'd been invited to
but not actually accepted yet, which automatically accepted the invites.
This was cool because Empathy didn't actually have a way to accept the
invite, but when I got back from lunch people were confused why I'd
joined the chat with Away / Lunch and then not said anything. :)
---
src/muc-channel.c | 4 ++++
tests/twisted/muc/test-muc-invitation.py | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/muc-channel.c b/src/muc-channel.c
index 1ad9c9b..a5eee89 100644
--- a/src/muc-channel.c
+++ b/src/muc-channel.c
@@ -3097,6 +3097,10 @@ gabble_muc_channel_send_presence (GabbleMucChannel *self,
LmMessage *msg;
gboolean result;
+ /* do nothing if we havn't actually joined yet */
+ if (priv->state < MUC_STATE_INITIATED)
+ return TRUE;
+
msg = create_presence_message (self, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL);
g_signal_emit (self, signals[PRE_PRESENCE], 0, msg);
result = _gabble_connection_send (priv->conn, msg, error);
diff --git a/tests/twisted/muc/test-muc-invitation.py b/tests/twisted/muc/test-muc-invitation.py
index 978f49f..db53037 100644
--- a/tests/twisted/muc/test-muc-invitation.py
+++ b/tests/twisted/muc/test-muc-invitation.py
@@ -61,16 +61,29 @@ def test(q, bus, conn, stream):
assert channel_props['InitiatorID'] == 'bob at localhost'
assert channel_props['InitiatorHandle'] == bob_handle
+ # set ourselves to away and back again, to check that we don't send any
+ # presence to the MUC before the invite has been accepted
+ conn.Presence.SetStatus({'away':{'message':'failure'}})
+ conn.Presence.SetStatus({'available':{'message':'success'}})
+
# accept the invitation
call_async(q, group_iface, 'AddMembers', [room_self_handle], 'Oh, OK then')
- _, event, _ = q.expect_many(
+ event, event2, _ = q.expect_many(
EventPattern('stream-presence', to='chat at conf.localhost/test'),
EventPattern('dbus-signal', signal='MembersChanged'),
EventPattern('dbus-return', method='AddMembers')
)
- assert event.args == ['', [], [bob_handle], [],
+ # check that the status we joined with was available / success
+ elem = event.stanza
+ show = [e for e in elem.elements() if e.name == 'show']
+ assert not show
+ status = [e for e in elem.elements() if e.name == 'status'][0]
+ assert status
+ assert status.children[0] == u'success'
+
+ assert event2.args == ['', [], [bob_handle], [],
[room_self_handle], 0, room_self_handle]
# Send presence for own membership of room.
--
1.5.6.5
More information about the Telepathy-commits
mailing list