示例#1
0
def remove_useless_labels(email_id):
    try:
        token = token_store.get_token(email_id, source)
        if (token == ""):
            token = token_store.get_token(email_id, source_2)
            use_psync = False
        # print use_psync, token
        nylas_helper.set_psync(use_psync)
        ns = nylas_helper.get_nylas_client(token)

        if use_psync:
            sync_url = psync_url
        else:
            sync_url = "https://api.nylas.com"

        if nylas_helper.use_labels(ns):
            for label in remove_label:
                lid = nylas_helper.get_id(ns, label)
                if lid is None:
                    continue
                url = sync_url + "/labels/" + lid
                response = requests.delete(url, auth=(token, ""))
                print label, ":", response
        else:
            for label in remove_label:
                lid = nylas_helper.get_folder_id(ns, label)
                if lid is None:
                    continue
                url = sync_url + "/folders/" + lid
                response = requests.delete(url, auth=(token, ""))
                print label, ":", response
    except Exception as e:
        print "Account doesn't exist"
    return
def remove_useless_labels(email_id):
	try:
		token = token_store.get_token(email_id, source)
		if(token == ""):
			token = token_store.get_token(email_id, source_2)
			use_psync = False
		# print use_psync, token
		nylas_helper.set_psync(use_psync)
		ns = nylas_helper.get_nylas_client(token)

		if use_psync:
			sync_url = psync_url
		else:
			sync_url = "https://api.nylas.com"
		
		if nylas_helper.use_labels(ns):
			for label in remove_label:
				lid = nylas_helper.get_id(ns, label)
				if lid is None:
					continue
				url = sync_url+"/labels/" + lid
				response = requests.delete(url, auth=(token, ""))
				print label,":",response
		else:
			for label in remove_label:
				lid = nylas_helper.get_folder_id(ns, label)
				if lid is None:
					continue
				url = sync_url+"/folders/" + lid
				response = requests.delete(url, auth=(token, ""))
				print label,":",response
	except Exception as e:
		print "Account doesn't exist"
	return
示例#3
0
def tag_new_mails(email_id,white_list):
	token = token_store.get_token(email_id, source)
	use_psync = True
	if(token == ""):
		token = token_store.get_token(email_id, source_2)
		use_psync = False
	# print use_psync, token
	nylas_helper.set_psync(use_psync)
	nylas_helper.tag_recent_unread_mails(email_id,token,white_list,social_list, use_psync)
	return
示例#4
0
def tag_new_mails(email_id, white_list):
    token = token_store.get_token(email_id, source)
    use_psync = True
    if (token == ""):
        token = token_store.get_token(email_id, source_2)
        use_psync = False
    # print use_psync, token
    nylas_helper.set_psync(use_psync)
    nylas_helper.tag_recent_unread_mails(email_id, token, white_list,
                                         social_list, use_psync)
    return