Beispiel #1
0
    def post(self):
        if not self.current_user:
            return self.send_error(403)

        push_id = self.request.arguments.get("id", [None])[0]
        if not push_id:
            return self.send_error(404)
        contents_query = self.generate_pushcontent_query(push_id)
        db.execute_cb(contents_query, self.get_push_request_users)
        people = self.people
        message = self.request.arguments.get("message", [None])[0]
        if not message:
            return self.send_error(500)

        irc_nick = Settings["irc"]["nickname"].format(pushmaster=self.current_user)

        if not people:
            irc_message = u"[[pushmaster {0}]] {1}".format(self.current_user, message)

            subprocess.call(["/nail/sys/bin/nodebot", "-i", irc_nick, Settings["irc"]["channel"], irc_message])
            return

        send_people_msg_in_groups(
            people,
            message,
            irc_nick,
            Settings["irc"]["channel"],
            person_per_group=5,
            prefix_msg="[[pushmaster %s]]" % self.current_user,
        )
Beispiel #2
0
def send_notifications(people, pushtype, pushmanager_url):
    pushmanager_servername = Settings['main_app']['servername']

    if people:
        msg = '%s: %s push starting! %s' % (', '.join(people), pushtype, pushmanager_url)
        XMPPQueue.enqueue_user_xmpp(people, 'Push starting! %s' % pushmanager_url)
    elif pushtype == 'morning':
        msg = 'Morning push opened. %s' % pushmanager_servername
    else:
        msg = 'push starting. %s' % pushmanager_url

    if people:
        send_people_msg_in_groups(
            people, "%s push starting! %s" % (pushtype, pushmanager_url),
            Settings['irc']['nickname'], Settings['irc']['channel'],
            person_per_group=5, prefix_msg=''
        )
    else:
        subprocess.call([
            '/nail/sys/bin/nodebot',
            '-i',
            Settings['irc']['nickname'],
            Settings['irc']['channel'],
            msg
        ])

    subject = "New push notification"
    MailQueue.enqueue_user_email(Settings['mail']['notifyall'], msg, subject)
Beispiel #3
0
    def post(self):
        if not self.current_user:
            return self.send_error(403)

        people = self.request.arguments.get('people[]', [])
        message = self.request.arguments.get('message', [None])[0]
        if not message:
            return self.send_error(500)

        irc_nick = Settings['irc']['nickname'].format(
            pushmaster=self.current_user
        )

        if not people:
            irc_message = u'[[pushmaster {0}]] {1}'.format(
                self.current_user,
                message,
            )

            subprocess.call([
                '/nail/sys/bin/nodebot',
                '-i',
                irc_nick,
                Settings['irc']['channel'],
                irc_message
            ])
            return


        send_people_msg_in_groups(
                                    people, message, irc_nick,
                                    Settings['irc']['channel'],
                                    person_per_group=5,
                                    prefix_msg='[[pushmaster %s]]' % self.current_user
                                )
Beispiel #4
0
    def test_send_people_msg_in_groups_split(self):
        people = ['111', '222', '333', '444', '555', '666']
        msg = 'Hello World!'
        irc_nick = 'Goku'
        irc_channel = 'dragon_ball'
        person_per_group = 5
        prefix_msg = '[fake_prefix_msg]'

        with contextlib.nested(
            mock.patch.object(subprocess, 'call', mock.Mock())
        ):
            send_people_msg_in_groups(people, msg, irc_nick, irc_channel, person_per_group, prefix_msg)

            T.assert_equal(subprocess.call.call_count, 2)
            subprocess.call.assert_any_call([
                '/nail/sys/bin/nodebot',
                '-i',
                'Goku',
                'dragon_ball',
                '[fake_prefix_msg] 111, 222, 333, 444, 555'
            ])

            subprocess.call.assert_any_call([
                '/nail/sys/bin/nodebot',
                '-i',
                'Goku',
                'dragon_ball',
                ' 666: Hello World!'
            ])
Beispiel #5
0
    def post(self):
        if not self.current_user:
            return self.send_error(403)

        push_id = self.request.arguments.get('id', [None])[0]
        if not push_id:
            return self.send_error(404)
        contents_query = self.generate_pushcontent_query(push_id)
        db.execute_cb(contents_query, self.get_push_request_users)
        people = self.people
        message = self.request.arguments.get('message', [None])[0]
        if not message:
            return self.send_error(500)

        irc_nick = Settings['irc']['nickname'].format(
            pushmaster=self.current_user
        )

        if not people:
            irc_message = u'[[pushmaster {0}]] {1}'.format(
                self.current_user,
                message,
            )

            subprocess.call([
                '/nail/sys/bin/nodebot',
                '-i',
                irc_nick,
                Settings['irc']['channel'],
                irc_message
            ])
            return

        send_people_msg_in_groups(
            people,
            message,
            irc_nick,
            Settings['irc']['channel'],
            person_per_group=5,
            prefix_msg='[[pushmaster %s]]' % self.current_user
        )