@wilm-ai/wilma-client 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parsers/messages.js +56 -3
- package/package.json +2 -2
package/dist/parsers/messages.js
CHANGED
|
@@ -79,9 +79,53 @@ export function parseMessageDetailHtml(html, messageId) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
let content = null;
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
82
|
+
const replyBoxes = $("div.m-replybox.hidden");
|
|
83
|
+
if (replyBoxes.length > 0) {
|
|
84
|
+
const otherReplies = replyBoxes.filter(function () {
|
|
85
|
+
return !$(this).hasClass("m-replybox-me");
|
|
86
|
+
});
|
|
87
|
+
if (otherReplies.length > 0) {
|
|
88
|
+
const latest = otherReplies.last();
|
|
89
|
+
const inner = latest.find("div.inner.hidden");
|
|
90
|
+
if (inner.length) {
|
|
91
|
+
content = inner.text().trim();
|
|
92
|
+
const replyHeaderText = latest.find("h2").first().text().trim();
|
|
93
|
+
const replySender = latest.find("a.profile-link").first();
|
|
94
|
+
if (replySender.length) {
|
|
95
|
+
senderName = replySender.text().trim();
|
|
96
|
+
sendersJson = {
|
|
97
|
+
senders: [
|
|
98
|
+
{
|
|
99
|
+
Name: senderName,
|
|
100
|
+
Href: replySender.attr("href"),
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const replySenderName = extractReplySenderName(replyHeaderText);
|
|
107
|
+
if (replySenderName) {
|
|
108
|
+
senderName = replySenderName;
|
|
109
|
+
sendersJson = {
|
|
110
|
+
senders: [
|
|
111
|
+
{
|
|
112
|
+
Name: senderName,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (replyHeaderText) {
|
|
119
|
+
sentAt = parseWilmaTimestamp(extractReplyTimestampText(replyHeaderText));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!content) {
|
|
125
|
+
const hidden = $("div.ckeditor.hidden").first();
|
|
126
|
+
if (hidden.length) {
|
|
127
|
+
content = hidden.text().trim();
|
|
128
|
+
}
|
|
85
129
|
}
|
|
86
130
|
if (!content && panelBody.length) {
|
|
87
131
|
const clone = cheerio.load(panelBody.html() ?? "");
|
|
@@ -138,3 +182,12 @@ export function debugMessageFields(data) {
|
|
|
138
182
|
function compactText(value) {
|
|
139
183
|
return value.replace(/\s+/g, " ").trim();
|
|
140
184
|
}
|
|
185
|
+
function extractReplyTimestampText(headerText) {
|
|
186
|
+
const absoluteDateTime = /(\d{1,2}\.\d{1,2}\.\d{4}\s+\d{1,2}:\d{2})/.exec(headerText);
|
|
187
|
+
return absoluteDateTime?.[1] ?? headerText;
|
|
188
|
+
}
|
|
189
|
+
function extractReplySenderName(headerText) {
|
|
190
|
+
const match = /^(.+?)\s+(?:vastasi|svarade|replied)\b/i.exec(compactText(headerText));
|
|
191
|
+
const sender = match?.[1]?.trim();
|
|
192
|
+
return sender || null;
|
|
193
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wilm-ai/wilma-client",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc -p tsconfig.json",
|
|
28
28
|
"lint": "echo 'add lint'",
|
|
29
|
-
"test": "
|
|
29
|
+
"test": "pnpm run build && node test/parser-messages.mjs",
|
|
30
30
|
"test:smoke": "tsc -p tsconfig.json && node test/smoke.mjs",
|
|
31
31
|
"test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
|
|
32
32
|
}
|