Bug 13623 - TextChannel should not send messages with the same id more than once
Summary: TextChannel should not send messages with the same id more than once
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-python (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-12 08:45 UTC by David Laban
Modified: 2010-04-16 15:00 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

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.