@@ -191,9 +191,10 @@ def _payload_has(cls, data, alias):
191191 return alias in cls ._group_aliased_data (data , cls .A .MESSAGE_CONTENT )
192192
193193 @classmethod
194- def _payload_relation_id (cls , data , alias ):
195- """Resource id under the payload's message_content resource node, or None."""
196- node_value = cls ._payload_node_value (data , alias )
194+ def _payload_relation_id (cls , data , alias , group = None ):
195+ """Resource id under a payload resource node, or None. Reads the
196+ message_content group unless another is named."""
197+ node_value = cls ._group_node_value (data , group or cls .A .MESSAGE_CONTENT , alias )
197198 if isinstance (node_value , list ):
198199 node_value = node_value [0 ] if node_value else {}
199200 return (node_value or {}).get (RESOURCE_ID )
@@ -225,7 +226,9 @@ def set_reply_recipient(cls, data, author_id):
225226 """Address a reply from its thread rather than the payload, so a third party
226227 joining a thread writes to the root's other party instead of whichever
227228 contributor the client happened to have selected."""
228- thread_id = cls ._reply_thread_id (data )
229+ thread_id = cls ._payload_relation_id (
230+ data , cls .A .RELATED_SOURCE_MESSAGE , cls .A .RELATED_SOURCE_MESSAGE
231+ )
229232 if not thread_id :
230233 return
231234 author_node , nodegroup_id = node_info (MESSAGE_GRAPH_SLUG , cls .A .MESSAGE_AUTHOR )
@@ -248,17 +251,6 @@ def set_reply_recipient(cls, data, author_id):
248251 if recipient :
249252 cls ._set_node (data , cls .A .RECIPIENT , [{RESOURCE_ID : recipient }])
250253
251- @classmethod
252- def _reply_thread_id (cls , data ):
253- """The thread root a create payload replies to, or None for a new thread."""
254- node_value = cls ._group_node_value (
255- data , cls .A .RELATED_SOURCE_MESSAGE , cls .A .RELATED_SOURCE_MESSAGE
256- )
257- if isinstance (node_value , list ):
258- node_value = node_value [0 ] if node_value else {}
259- thread_id = (node_value or {}).get (RESOURCE_ID )
260- return str (thread_id ) if thread_id else None
261-
262254 @classmethod
263255 def _set_node (cls , data , alias , node_value ):
264256 """Set a node's value in the payload's message_content group, creating the path."""
0 commit comments