Exemplo n.º 1
0
    def mailinglist_reply(self, group_id, thread_id):
        try:
            group = Group.get(int(group_id))
            thread_id = int(thread_id)
        except ValueError:
            abort(404)
        thread = GroupMailingListMessage.get(thread_id, group.id)

        if group is None or thread is None:
            abort(404)

        last_post = thread.posts[-1]
        msg = post_message(group,
                           c.user,
                           u"Re: %s" % thread.subject,
                           self.form_result['message'],
                           reply_to=last_post.message_id)

        if request.params.has_key('js'):
            return render_mako_def('/sections/wall_entries.mako',
                                   'thread_reply',
                                   id=msg.id,
                                   author_id=msg.author_id if msg.author_id is not None else msg.author_or_anonymous,
                                   message=msg.body,
                                   created_on=msg.sent,
                                   attachments=msg.attachments,
                                   allow_comment_deletion=False)
        else:
            self._redirect()
Exemplo n.º 2
0
def post_message(group, user, subject, message, reply_to=None, force=False, attachments=[]):
    msgstr = compose_email(user.email.email,
                           group.list_address,
                           subject,
                           message,
                           message_id=_generateMessageId(),
                           send_to=group.recipients_mailinglist(),
                           reply_to=reply_to,
                           list_id=group.list_address)
    post = GroupMailingListMessage.fromMessageText(msgstr, force=force)
    post.group = group
    if attachments:
        for attachment in attachments:
            attachment.parent = post
        post.attachments.extend(attachments)
    meta.Session.commit()
    if not post.in_moderation_queue:
        post.send(group.recipients_mailinglist())
    return post