diff --git a/rattail/db/model/messages.py b/rattail/db/model/messages.py index 9720b24b..0da97516 100644 --- a/rattail/db/model/messages.py +++ b/rattail/db/model/messages.py @@ -74,6 +74,16 @@ class Message(Base): kwargs['recipient'] = user self.recipients.append(MessageRecipient(**kwargs)) + def has_recipient(self, user): + """ + Returns boolean indicating whether the given user is listed among the + message's recipients. + """ + for recipient in self.recipients: + if recipient.recipient is user: + return True + return False + class MessageRecipient(Base): """