reply message from thread and room

This commit is contained in:
grimhilt
2023-04-14 20:54:44 +02:00
parent 7ad22e55c1
commit 4799e477be
10 changed files with 117 additions and 20 deletions

View File

@@ -11,7 +11,7 @@ import {
getThreadInfoOnId,
} from "../../db/message/saveMessage-db";
import { findRoomByOwner, getAddresseId, getUserIdOfMailbox } from "../../db/utils/mail";
import { findRoomByOwner, getAddressId, getUserIdOfMailbox } from "../../db/utils/mail";
import { nbMembers } from "../utils/envelopeUtils";
import logger from "../../system/Logger";
import { Attrs, Envelope, User } from "../../interfaces/mail/attrs.interface";
@@ -57,7 +57,7 @@ export default class RegisterMessageInApp {
async init() {
if (this.envelope.from) {
this.ownerId = await getAddresseId(createAddress(this.envelope.from[0])); // todo use sender or from ?
this.ownerId = await getAddressId(createAddress(this.envelope.from[0])); // todo use sender or from ?
} else {
throw new Error("Envelope must have a 'from' field");
}
@@ -152,7 +152,7 @@ export default class RegisterMessageInApp {
if (this.isDm()) {
// create or add new message to DM
if (!this.envelope.to) throw new Error("Who send a DM and put the recipient in cc ?");
const userTo = await getAddresseId(createAddress(this.envelope.to[0]));
const userTo = await getAddressId(createAddress(this.envelope.to[0]));
await this.createOrRegisterOnExistence(userTo, RoomType.DM);
} else {
// it is not a reply and not a dm

View File

@@ -1,4 +1,4 @@
import { getAddresseId, getFlagId } from "../../db/utils/mail";
import { getAddressId, getFlagId } from "../../db/utils/mail";
import { EmailAddress, ParsedMail, simpleParser } from "mailparser";
import moment from "moment";
import Imap from "imap";
@@ -91,7 +91,7 @@ async function saveFromParsedData(parsed: ParsedMail, messageId: number) {
// save address field
getFieldId(key).then((fieldId) => {
parsed[key].value.forEach((addr: EmailAddress, nb: number) => {
getAddresseId(addr.address, addr.name).then(async (addressId) => {
getAddressId(addr.address, addr.name).then(async (addressId) => {
await saveAddress_fields(messageId, fieldId, addressId, nb);
});
});

View File

@@ -13,7 +13,7 @@ export default class MailBuilder {
this.message.to = addresses;
return this;
}
cc(addresses: string[] | string): MailBuilder {
this.message.cc = addresses;
return this;
@@ -43,4 +43,10 @@ export default class MailBuilder {
this.message.inReplyTo = messageID;
return this;
}
}
inReplySubject(originSubject: string): MailBuilder {
// todo concate if multiple ?
this.message.subject = "RE: " + originSubject;
return this;
}
}