Beispiel #1
0
def user_channel_delete(channel_name, username):
    try:
        if channel_name == Channel.DEFAULT:
            return error_view(500, "cannot unlink default channel")

        user_channel = UserChannel.get(username, channel_name)
        user_channel.delete()
        return user_ch_deleted_view(user_channel)
    except ObjectNotFound:
        return error_view(404, "user channel not found")
Beispiel #2
0
def user_channel_put(channel_name, username):
    try:
        token = request.args.get('token')
        if token is None or token == '':
            return error_view(400, 'missing token')

        user_channel = UserChannel.get(username, channel_name)
        if user_channel.verified:
            return error_view(500, 'this channel has already been verified')

        if token != user_channel.token:
            return error_view(500, 'invalid token')

        user_channel.update(verified=True)
        return user_ch_updated_view(user_channel)

    except ObjectNotFound:
        return error_view(404, "user channel not found")
Beispiel #3
0
def channel_test(channel_name):
    try:
        username = get_jwt_identity()
        if request.method == 'GET':
            user = User.get(username)
            channel = Channel.get(channel_name)
            user_channel = UserChannel.get(user.username, channel.name)

            template = TEST_TEMPLATE
            template.set_format(date=str(datetime.now().date()))
            send(user_channel.contact, channel, template)

            return user_ch_test_view(user_channel)

    except ObjectNotFound:
        return error_view(404, "object not found")

    except (MailSendingError, TelegramSendingError):
        return error_view(500, "failed to send test")
Beispiel #4
0
def user_channel_get(channel_name, username):
    try:
        user_channel = UserChannel.get(username, channel_name)
        return user_ch_get_view(user_channel)
    except ObjectNotFound:
        return error_view(404, "user channel not found")