( message: Element, )
| 52 | childOf(el, name)?.textContent ?? undefined; |
| 53 | |
| 54 | export 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 | |
| 77 | type ParseOptions = { |
| 78 | ownBareJid: string; |
no test coverage detected