def _toggle_like(doctype, name, add, user=None):

	if not user:
		user = frappe.session.user

	try:
		liked_by = frappe.db.get_value(doctype, name, "_liked_by")

		# CHANGED: Allow someone to like their own documents as it also works as a bookmark
		# if owner==frappe.session.user and add=="Yes":
		# 	frappe.throw(_("You cannot like something that you created"))

		if liked_by:
			liked_by = json.loads(liked_by)
		else:
			liked_by = []

		if add=="Yes":
			if user not in liked_by:
				liked_by.append(user)
				add_comment(doctype, name)

		else:
			if user in liked_by:
				liked_by.remove(user)
				remove_like(doctype, name)

		frappe.db.set_value(doctype, name, "_liked_by", json.dumps(liked_by), update_modified=False)

	except Exception, e:
		if isinstance(e.args, (tuple, list)) and e.args and e.args[0]==1054:
			add_column(doctype, "_liked_by", "Text")
			_toggle_like(doctype, name, add, user)
		else:
			raise
Same as toggle_like but hides param `user` from API
dataset/ETHPy150Open frappe/frappe/frappe/desk/like.py/_toggle_like