def click(id): result = { } try: link = database.get_link_by_id(id) if link.unread and not link.starred: result['moved_to_archive'] = True database.archive_link(id) else: result['moved_to_archive'] = False database.mark_link_as_read(id) result['success'] = True except Exception as error: result = { 'success': False, 'message': str(error) } return jsonify(result)
def unstar(id): result = { } try: database.mark_link_as_unstarred(id) link = database.get_link_by_id(id) if link.unread: result['moved_to_archive'] = False result['moved_to_inbox'] = True else: result['moved_to_archive'] = True result['moved_to_inbox'] = False database.archive_link(id) result['success'] = True except Exception as error: result = { 'success': False, 'message': str(error) } return jsonify(result)