コード例 #1
0
 def __init__(self, extension):
     self.extension = extension
     self.sender = XmppSender(extension)
コード例 #2
0
 def __init__(self, extension):
     self.extension = extension
     self.sender = XmppSender(extension)
コード例 #3
0
class XmppSignals(object):
    def __init__(self, extension):
        self.extension = extension
        self.sender = XmppSender(extension)

    def review_request_published_cb(self, sender, user, review_request, changedesc,
                                **kwargs):
        """
        Listens to the ``review_request_published`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(u"XmppSignal review_request_published_cb by %s %s for #%s; sender %s", user.first_name, user.last_name, review_request.get_display_id(),sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_request_published(user, review_request, changedesc)

    def review_request_reopened_cb(self, sender, user, review_request,
                                **kwargs):
        """
        Listens to the ``review_request_published`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(u"XmppSignal review_request_reopened_cb by %s %s for #%s; sender %s", user.first_name, user.last_name, review_request.get_display_id(),sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_request_reopened(user, review_request)

    def review_request_closed_cb(self, sender, user, review_request, **kwargs):
        """Sends notification when a review request is closed.

        Listens to the ``review_request_closed`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_close_notify`` site configuration).
        """
        logging.debug(u"XmppSignal review_request_closed_cb by %s %s for #%s; sender %s", user.first_name, user.last_name, review_request.get_display_id(),sender)
        if self.extension.settings['xmpp_send_review_close_notify']:
            self.sender.send_review_request_closed(user, review_request)

    def review_published_cb(self, sender, user, review, **kwargs):
        """
        Listens to the ``review_published`` signal and sends a notification if
        this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(u"XmppSignal review_published_cb by %s %s for #%s; sender %s", user.first_name, user.last_name,
            review.review_request.get_display_id(),  sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_published(user, review)

    def reply_published_cb(self, sender, user, reply, **kwargs):
        """
        Listens to the ``reply_published`` signal and sends a notification if
        this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(u"XmppSignal reply_published_cb by %s %s for #%s; sender %s", user.first_name, user.last_name,
            reply.base_reply_to.review_request.get_display_id(), sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_reply_published(user, reply)

    def user_registered_cb(self, user, **kwargs):
        """
        Listens for new user registrations and sends a new user registration
        notification to administrators, if enabled.
        """
        logging.debug(u"XmppSignals user_registered_cb %s %s", user.first_name, user.last_name)
        if self.extension.settings['xmpp_send_new_user_notify']:
            self.sender.send_xmpp_message(user, "Welcome to ReviewBoard")

    def register_signals(self):
            review_request_published.connect(self.review_request_published_cb,
                                             sender=ReviewRequest, dispatch_uid="rbxmppnotification")
            review_published.connect(self.review_published_cb, sender=Review, dispatch_uid="rbxmppnotification")
            reply_published.connect(self.reply_published_cb, sender=Review, dispatch_uid="rbxmppnotification")
            review_request_closed.connect(self.review_request_closed_cb,
                                          sender=ReviewRequest, dispatch_uid="rbxmppnotification")
            review_request_reopened.connect(self.review_request_reopened_cb,
                                          sender=ReviewRequest, dispatch_uid="rbxmppnotification")
            user_registered.connect(self.user_registered_cb, dispatch_uid="rbxmppnotification")
コード例 #4
0
class XmppSignals(object):
    def __init__(self, extension):
        self.extension = extension
        self.sender = XmppSender(extension)

    def review_request_published_cb(self, sender, user, review_request,
                                    changedesc, **kwargs):
        """
        Listens to the ``review_request_published`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(
            u"XmppSignal review_request_published_cb by %s %s for #%s; sender %s",
            user.first_name, user.last_name, review_request.get_display_id(),
            sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_request_published(user, review_request,
                                                      changedesc)

    def review_request_reopened_cb(self, sender, user, review_request,
                                   **kwargs):
        """
        Listens to the ``review_request_published`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(
            u"XmppSignal review_request_reopened_cb by %s %s for #%s; sender %s",
            user.first_name, user.last_name, review_request.get_display_id(),
            sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_request_reopened(user, review_request)

    def review_request_closed_cb(self, sender, user, review_request, **kwargs):
        """Sends notification when a review request is closed.

        Listens to the ``review_request_closed`` signal and sends a
        notification if this type of notification is enabled (through
        ``xmpp_send_review_close_notify`` site configuration).
        """
        logging.debug(
            u"XmppSignal review_request_closed_cb by %s %s for #%s; sender %s",
            user.first_name, user.last_name, review_request.get_display_id(),
            sender)
        if self.extension.settings['xmpp_send_review_close_notify']:
            self.sender.send_review_request_closed(user, review_request)

    def review_published_cb(self, sender, user, review, **kwargs):
        """
        Listens to the ``review_published`` signal and sends a notification if
        this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(
            u"XmppSignal review_published_cb by %s %s for #%s; sender %s",
            user.first_name, user.last_name,
            review.review_request.get_display_id(), sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_review_published(user, review)

    def reply_published_cb(self, sender, user, reply, **kwargs):
        """
        Listens to the ``reply_published`` signal and sends a notification if
        this type of notification is enabled (through
        ``xmpp_send_review_notify`` site configuration).
        """
        logging.debug(
            u"XmppSignal reply_published_cb by %s %s for #%s; sender %s",
            user.first_name, user.last_name,
            reply.base_reply_to.review_request.get_display_id(), sender)
        if self.extension.settings['xmpp_send_review_notify']:
            self.sender.send_reply_published(user, reply)

    def user_registered_cb(self, user, **kwargs):
        """
        Listens for new user registrations and sends a new user registration
        notification to administrators, if enabled.
        """
        logging.debug(u"XmppSignals user_registered_cb %s %s", user.first_name,
                      user.last_name)
        if self.extension.settings['xmpp_send_new_user_notify']:
            self.sender.send_xmpp_message(user, "Welcome to ReviewBoard")

    def register_signals(self):
        review_request_published.connect(self.review_request_published_cb,
                                         sender=ReviewRequest,
                                         dispatch_uid="rbxmppnotification")
        review_published.connect(self.review_published_cb,
                                 sender=Review,
                                 dispatch_uid="rbxmppnotification")
        reply_published.connect(self.reply_published_cb,
                                sender=Review,
                                dispatch_uid="rbxmppnotification")
        review_request_closed.connect(self.review_request_closed_cb,
                                      sender=ReviewRequest,
                                      dispatch_uid="rbxmppnotification")
        review_request_reopened.connect(self.review_request_reopened_cb,
                                        sender=ReviewRequest,
                                        dispatch_uid="rbxmppnotification")
        user_registered.connect(self.user_registered_cb,
                                dispatch_uid="rbxmppnotification")