reply message from thread and room
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user