예제 #1
0
def list_inactive(obj, days, null=False):
    """List inacitve users.

    WARNING! THIS IS NOT OFFICIALLY SUPPORTED BY FLOWDOCK API!

    Users are considered if they haven't used the Flowdock organization during
    last 90 days (customizable, see --days).

    By passing option --null list users who have not been active at all or the
    last time was before flowdock started collecting statistics.
    """
    click.secho("WARNING! This method is not supported by Flowdock!",
                bold=True, fg='red')

    if null:
        click.echo("Listing users that have not been active at all")
    else:
        click.echo("Listing users who have not been active during last {} days"
                   .format(days))

    f = Flowdock(obj['APIKEY'], debug=obj['DEBUG'], print_function=click.echo)
    orgs = f.list_organizations()
    for org in orgs:
        inactive = f.find_inactive_in_org(org['parameterized_name'], days, null)
        if len(inactive) > 0:
            click.echo(org['name'])
            for user in inactive:
                click.echo("    {}, {}".format(user['email'], user['accessed_at']))

    f.close()
예제 #2
0
파일: service.py 프로젝트: or/jeeves
def notify_flowdock(token, channel, event, build=None, job=None):
    if not build:
        build = job.build

    notification_metadata, unused_created = NotificationMetadata.objects.get_or_create(
        build=build, defaults={"data": {}}
    )

    if not notification_metadata.data:
        notification_metadata.data = {}

    if "theme" not in notification_metadata.data:
        notification_metadata.data["theme"] = get_emoji_theme()

    if "flowdock" in notification_metadata.data:
        thread_id = notification_metadata.data["flowdock"].get("thread_id")
    else:
        thread_id = None

    notification_metadata.save()

    flowdock = Flowdock(token=token)

    flowdock_message = make_flowdock_message(event, build=build, job=job)
    if not flowdock_message:
        return

    message, tags = flowdock_message

    msg = flowdock.message(channel, message, tags=tags, thread_id=thread_id)
    if "flowdock" not in notification_metadata.data:
        notification_metadata.data["flowdock"] = msg
        notification_metadata.save()
예제 #3
0
def list_orgs(obj):
    """List flowdock organizations this user is part of."""
    click.echo("Getting organization list...")
    f = Flowdock(obj['APIKEY'], debug=obj['DEBUG'], print_function=click.echo)
    orgs = f.list_organizations()
    f.close()
    for org in orgs:
        print_org(org)
예제 #4
0
def find_user(obj, email):
    """List the organizations the given user belongs to"""
    click.echo("Listing the organizations {} belongs to".format(email))
    f = Flowdock(obj['APIKEY'], debug=obj['DEBUG'], print_function=click.echo)
    user_orgs = f.find_user_orgs(email)
    if len(user_orgs == 0):
        click.echo("User not found!")
    click.echo("User is part of the following Flowdock organizations:")
    for org in user_orgs:
        click.echo(org['name'])
예제 #5
0
def delete_user(obj, email,):
    """Delete user with given EMAIL address from all Flowdock organizations."""
    click.echo("Deleting user {} from all organizations...".format(email))
    f = Flowdock(obj['APIKEY'], debug=obj['DEBUG'], print_function=click.echo)
    orgs = f.find_user_orgs()
    if len(orgs == 0):
        click.echo("User not found!")
        return
    click.echo("User is part of the following Flowdock organizations:")
    for org in orgs:
        click.echo(org['name'])
    if click.confirm('Are you sure you want to delete user?'):
        __delete_user_from_orgs(f, email, orgs)
        click.echo('Done!')