Bug 13623

Summary: TextChannel should not send messages with the same id more than once
Product: Telepathy Reporter: David Laban <alsuren>
Component: tp-pythonAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description David Laban 2007-12-12 08:45:27 UTC
currently: (in telepathy-python/telepathy/server/channel.py:269)

    @dbus.service.signal(CHANNEL_TYPE_TEXT, signature='uuuuus')
    def Received(self, id, timestamp, sender, type, flags, text):
        self._pending_messages[id] = (timestamp, sender, type, flags, text)

This will always emit a signal

I suggest either:
creating a standard wrapper (so that users don't have to):

    def received(self, id, timestamp, sender, type, flags, text):
        """Wrapper around broken Received signal"""
        if id not in self._pending_messages:
            self.Received(id, timestamp, sender, type, flags, text)

or raising ValueError, to stop the signal being transmitted:

    @dbus.service.signal(CHANNEL_TYPE_TEXT, signature='uuuuus')
    def Received(self, id, timestamp, sender, type, flags, text):
        if id in self._pending_messages:
            raise ValueError("You can't receive the same message twice.")
        else:
            self._pending_messages[id] = (timestamp, sender, type, flags, text)
Comment 1 Jonny Lamb 2010-04-16 15:00:37 UTC
(In reply to comment #0)
> or raising ValueError, to stop the signal being transmitted:

Seems fair. I pushed a commit to fix this.

(Next time, please give a git format-patch patch!)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.