Switch to instead use SVG format for content body
This commit is contained in:
parent
1d33657569
commit
1de3cc148e
2 changed files with 33 additions and 58 deletions
|
|
@ -526,10 +526,19 @@ class Util {
|
|||
// Integerize
|
||||
filteredData = filteredData.map(n => parseInt((n * 255).toFixed()));
|
||||
|
||||
const base64 = Buffer.from(filteredData).toString('base64'); //.replace(/=/g, '')
|
||||
console.log("BASE64", base64);
|
||||
|
||||
// Generate SVG of waveform
|
||||
let svg = `<svg viewBox="0 0 ${samples} 255" fill="none" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">`;
|
||||
svg += `<path d="`;
|
||||
filteredData.forEach((d, i) => {
|
||||
const delta = d / 2;
|
||||
svg += `M${i} ${128 - delta}V${128 + delta}`;
|
||||
});
|
||||
svg += `" style="fill:none;stroke:green;stroke-width:1" />`;
|
||||
svg += "</svg>";
|
||||
|
||||
messageContent.format = "org.matrix.custom.html";
|
||||
messageContent.formatted_body = base64;
|
||||
messageContent.formatted_body = svg;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue