def update_comment_in_doc(doc):

	if doc.communication_type not in ("Comment", "Communication"):
		return

	if doc.communication_type == 'Comment' and doc.comment_type != 'Comment':
		# other updates
		return

	def get_content(doc):
		return (doc.content[:97] + '...') if len(doc.content) > 100 else doc.content

	if doc.reference_doctype and doc.reference_name and doc.content:
		_comments = get_comments_from_parent(doc)

		updated = False
		for c in _comments:
			if c.get("name")==doc.name:
				c["comment"] = get_content(doc)
				updated = True

		if not updated:
			_comments.append({
				"comment": get_content(doc),
				"by": doc.sender or doc.owner,
				"name": doc.name
			})

		update_comments_in_parent(doc.reference_doctype, doc.reference_name, _comments)
Updates `_comments` (JSON) property in parent Document.
dataset/ETHPy150Open frappe/frappe/frappe/core/doctype/communication/comment.py/update_comment_in_doc