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:
+2
-2
@@ -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,
|
||||
};
|
||||
|
||||
+35
-25
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user