~vesto/feedon

b963a5fd5038de2d757eab6c8a78fe10b4a417a7 — Steve Gattuso 6 months ago bf6896e
fix deletion of timelines
1 files changed, 6 insertions(+), 6 deletions(-)

M feedon/services/timelines.py
M feedon/services/timelines.py => feedon/services/timelines.py +6 -6
@@ 6,20 6,20 @@ def sync_timelines(user: db.User):
    remote_lists = client.get(user.instance_url('/api/v1/lists'))
    utils.validate_request(remote_lists)

    remote_ids = {l['id'] for l in remote_lists.json()}
    remote_ids = {int(l['id']) for l in remote_lists.json()}

    local_lists = db.Timeline.select().where(
        db.Timeline.user_id == user.id
    )
    local_ids = {l.remote_id for l in local_lists}
    local_ids = {int(l.remote_id) for l in local_lists}

    # Delete any lists that we have stored locally but no longer exist on
    # their account
    to_delete = local_lists - remote_ids - {-1, -2, -3}
    to_delete = local_ids - remote_ids - {-1, -2, -3}
    db.Timeline.delete().where(
        db.Timeline.id.in_(to_delete) &
        db.Timeline.user_id == user.id
    )
        (db.Timeline.remote_id.in_(to_delete)) &
        (db.Timeline.user_id == user.id)
    ).execute()

    # Update all existing lists
    for remote_list in remote_lists.json():