Chatroom invitations
Brad Fitzpatrick
brad at danga.com
Thu Nov 8 01:10:49 UTC 2007
That code is also pretty horrendous looking. Don't reach into object
internals. Use accessor methods, etc. If object-oriented APIs don't
exist for what you need, add them. But I bet they're already there,
waiting to be used.
- Brad
Clive Holloway wrote:
> Thanks for the input. On further testing I found that this isn't
> sufficient. I wasn't going to repost until I was completely sure, but
> anyway.
>
> My revised conditional breaks on actual chat messages. What I'm using now is:
>
> if ($stanza->isa("DJabberd::Message")
> && ref $stanza->{children}[0]
> && $stanza->{children}[0]{element} eq 'x'
> && ! ref $stanza->{children}[1]
> && ref $stanza->{children}[0]{children}[0]
> && $stanza->{children}[0]{children}[0]{element} eq 'invite') {
>
> It works for what I need it for, but I think until I completely
> understand the code, I'll refrain from offering patches or anything
> like that :)
>
> cLive ;-)
>
> On Nov 7, 2007 1:35 PM, Peter Saint-Andre <stpeter at stpeter.im> wrote:
>
>> Martin Atkins wrote:
>>
>>> Clive Holloway wrote:
>>>
>>>> This snippet allows chatroom members to send invites to other users.
>>>>
>>>>
>>> [snip]
>>>
>>>> if ($stanza->isa("DJabberd::Message")
>>>> && $stanza->{children}[0]{element} eq 'x'
>>>> && $stanza->{children}[0]{children}[0]{element} eq
>>>> 'invite') {
>>>>
>>>>
>>> This seems risky, since I believe <message> stanzas can come with a
>>> <body> in them for fallback in clients without MUC support, like this:
>>>
>>> <message ...>
>>> <subject>Conference Invitation</subject>
>>> <body>Please join me in the conference room "blah"
>>> on conference.example.com.</body>
>>> <x xmlns="jabber:x:conference">
>>> <invite ... />
>>> </x>
>>> </message>
>>>
>>> Probably should also verify the namespace of that "x" element, too. The
>>> MUC spec seems to suggest that it should be:
>>> <http://jabber.org/protocol/muc#user>
>>>
>> Correct. The jabber:x:conference was an old namespace we used back in
>> 2000/2001 and it has been deprecated for some time now.
>>
>> Peter
>>
>> --
>> Peter Saint-Andre
>> https://stpeter.im/
>>
>>
>>
More information about the Djabberd
mailing list