Update workspace entities to make all TEXT nullable (#16144)

Follow up on #15926

---------

Co-authored-by: Etienne <45695613+etiennejouan@users.noreply.github.com>
Co-authored-by: guillim <guigloo@msn.com>
This commit is contained in:
Charles Bochet
2025-11-28 10:50:38 +01:00
committed by GitHub
parent 9620a4b0ba
commit eb362c6d5f
63 changed files with 396 additions and 136 deletions
@@ -75,8 +75,8 @@ export class TimelineMessagingService {
return {
id: messageThread.id,
subject: firstMessage.subject,
lastMessageBody: lastMessage.text,
subject: firstMessage.subject ?? '',
lastMessageBody: lastMessage.text ?? '',
lastMessageReceivedAt: lastMessage.receivedAt ?? new Date(),
numberOfMessagesInThread: messageThread.messages.length,
};
@@ -1,30 +1,40 @@
import { isDefined } from 'twenty-shared/utils';
import { type TimelineThreadParticipantDTO } from 'src/engine/core-modules/messaging/dtos/timeline-thread-participant.dto';
import { type MessageParticipantWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-participant.workspace-entity';
export const formatThreadParticipant = (
threadParticipant: MessageParticipantWorkspaceEntity,
): TimelineThreadParticipantDTO => ({
personId: threadParticipant.personId,
workspaceMemberId: threadParticipant.workspaceMemberId,
firstName:
threadParticipant.person?.name?.firstName ||
threadParticipant.workspaceMember?.name.firstName ||
'',
lastName:
threadParticipant.person?.name?.lastName ||
threadParticipant.workspaceMember?.name.lastName ||
'',
displayName:
threadParticipant.person?.name?.firstName ||
threadParticipant.person?.name?.lastName ||
threadParticipant.workspaceMember?.name.firstName ||
threadParticipant.workspaceMember?.name.lastName ||
threadParticipant.displayName ||
threadParticipant.handle ||
'',
avatarUrl:
threadParticipant.person?.avatarUrl ||
threadParticipant.workspaceMember?.avatarUrl ||
'',
handle: threadParticipant.handle,
});
): TimelineThreadParticipantDTO => {
if (!isDefined(threadParticipant.handle)) {
throw new Error(
`Thread participant ${threadParticipant.id} has an empty handle`,
);
}
return {
personId: threadParticipant.personId,
workspaceMemberId: threadParticipant.workspaceMemberId,
firstName:
threadParticipant.person?.name?.firstName ||
threadParticipant.workspaceMember?.name.firstName ||
'',
lastName:
threadParticipant.person?.name?.lastName ||
threadParticipant.workspaceMember?.name.lastName ||
'',
displayName:
threadParticipant.person?.name?.firstName ||
threadParticipant.person?.name?.lastName ||
threadParticipant.workspaceMember?.name.firstName ||
threadParticipant.workspaceMember?.name.lastName ||
threadParticipant.displayName ||
threadParticipant.handle ||
'',
avatarUrl:
threadParticipant.person?.avatarUrl ||
threadParticipant.workspaceMember?.avatarUrl ||
'',
handle: threadParticipant.handle,
};
};