Generate color hashes for comment authors
This commit is contained in:
parent
1f5889dc39
commit
ec5bb4a4a8
@ -9,10 +9,12 @@
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/color-hash": "^2.0.0",
|
||||
"@types/imapflow": "^1.0.19",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/mailparser": "^3.4.5",
|
||||
"blakejs": "^1.2.1",
|
||||
"color-hash": "^2.0.2",
|
||||
"imapflow": "^1.0.171",
|
||||
"isomorphic-dompurify": "^2.19.0",
|
||||
"jsdom": "^25.0.1",
|
||||
|
@ -7,6 +7,7 @@ import {config} from "../config.ts";
|
||||
import { marked } from "marked";
|
||||
import {sanitizeHtml} from "../mail/sanitize.ts";
|
||||
import {formatThreadAddress} from "./id.ts";
|
||||
import ColorHash from "color-hash";
|
||||
|
||||
export async function refreshThreadsEntirely(): Promise<void> {
|
||||
await withClient(async client => {
|
||||
@ -46,6 +47,7 @@ export async function refreshThreadsEntirely(): Promise<void> {
|
||||
// Pass 1: create all the ThreadComment instances and make a map by their ID
|
||||
const commentsByHash: {[hash: string]: ThreadComment} = {}
|
||||
const messages = messagesByThread[threadId]
|
||||
const colorHash = new ColorHash();
|
||||
for ( const message of messages ) {
|
||||
if (
|
||||
!threadData.refresh.markers[message.mailbox]
|
||||
@ -62,6 +64,7 @@ export async function refreshThreadsEntirely(): Promise<void> {
|
||||
name: message.from.name || '(anonymous)',
|
||||
mailId: sha256(message.from.address!.toLowerCase()),
|
||||
domainId: sha256(message.from.address!.toLowerCase().split('@').reverse()[0]),
|
||||
color: colorHash.hex(message.from.address!.toLowerCase()),
|
||||
},
|
||||
date: message.date,
|
||||
subject: message.subject,
|
||||
|
@ -51,6 +51,7 @@ export type ThreadUser = {
|
||||
name: string,
|
||||
mailId: string,
|
||||
domainId: string,
|
||||
color: string,
|
||||
}
|
||||
|
||||
export type ThreadComment = {
|
||||
|
Loading…
Reference in New Issue
Block a user