MCPcopy Create free account
hub / github.com/dailydotdev/apps / parseCommentRef

Function parseCommentRef

packages/shared/src/features/messages/stanzas.ts:54–75  ·  view source on GitHub ↗
(
  message: Element,
)

Source from the content-addressed store, hash-verified

52 childOf(el, name)?.textContent ?? undefined;
53
54export const parseCommentRef = (
55 message: Element,
56): DmCommentContext | undefined => {
57 const ref = childOf(message, 'comment-ref', NS_COMMENT_REF);
58 const commentId = ref?.getAttribute('id');
59 const authorId = ref?.getAttribute('author-id');
60 const permalink = ref?.getAttribute('url');
61 const snippet = ref && textOf(ref, 'snippet');
62
63 if (!ref || !commentId || !authorId || !permalink || !snippet) {
64 return undefined;
65 }
66
67 return {
68 type: 'comment',
69 commentId,
70 authorId,
71 permalink,
72 snippet,
73 postTitle: textOf(ref, 'title'),
74 };
75};
76
77type ParseOptions = {
78 ownBareJid: string;

Callers 1

parseChatMessageFunction · 0.85

Calls 2

childOfFunction · 0.70
textOfFunction · 0.70

Tested by

no test coverage detected