Skip to content

Commit

Permalink
Merge branch 'main' into feat/data-explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-elias committed Aug 16, 2024
2 parents dfb501a + 20d8475 commit ffe3661
Show file tree
Hide file tree
Showing 16 changed files with 506 additions and 552 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyledItemsContainer = styled.div`
align-items: center;
display: flex;
flex-direction: column;
gap: 12px;
gap: 14px;
height: calc(100dvh - 32px);
margin-bottom: auto;
max-width: 204px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const StyledContainer = styled.div<{ isSubMenu?: boolean }>`
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: ${({ theme }) => theme.spacing(3)};
gap: ${({ theme }) => theme.spacing(3.5)};
height: 100%;
min-width: ${DESKTOP_NAV_DRAWER_WIDTHS.menu}px;
padding: ${({ theme }) => theme.spacing(3, 2, 4)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const StyledContainer = styled.div<{ isMultiWorkspace: boolean }>`
display: flex;
gap: ${({ theme, isMultiWorkspace }) =>
!isMultiWorkspace ? theme.spacing(2) : null};
padding: ${({ theme, isMultiWorkspace }) =>
!isMultiWorkspace ? theme.spacing(1) : null};
height: ${({ theme }) => theme.spacing(8)};
user-select: none;
`;
Expand Down
3 changes: 3 additions & 0 deletions packages/twenty-front/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@ export default defineConfig(({ command, mode }) => {
localsConvention: 'camelCaseOnly',
},
},
optimizeDeps: {
exclude: ['@tabler/icons-react'],
},
};
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ObjectType, Field } from '@nestjs/graphql';
import { Field, ObjectType } from '@nestjs/graphql';

import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';

@ObjectType('TimelineThreadParticipant')
export class TimelineThreadParticipant {
@Field(() => UUIDScalarType, { nullable: true })
personId: string;
personId: string | null;

@Field(() => UUIDScalarType, { nullable: true })
workspaceMemberId: string;
workspaceMemberId: string | null;

@Field()
firstName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { Injectable } from '@nestjs/common';

import { TIMELINE_THREADS_DEFAULT_PAGE_SIZE } from 'src/engine/core-modules/messaging/constants/messaging.constants';
import { TimelineThreadsWithTotal } from 'src/engine/core-modules/messaging/dtos/timeline-threads-with-total.dto';
import { TimelineMessagingService } from 'src/engine/core-modules/messaging/services/timeline-messaging.service';
import { formatThreads } from 'src/engine/core-modules/messaging/utils/format-threads.util';
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';

@Injectable()
export class GetMessagesService {
constructor(
private readonly twentyORMManager: TwentyORMManager,
private readonly timelineMessagingService: TimelineMessagingService,
) {}

async getMessagesFromPersonIds(
workspaceMemberId: string,
personIds: string[],
page = 1,
pageSize: number = TIMELINE_THREADS_DEFAULT_PAGE_SIZE,
): Promise<TimelineThreadsWithTotal> {
const offset = (page - 1) * pageSize;

const { messageThreads, totalNumberOfThreads } =
await this.timelineMessagingService.getAndCountMessageThreads(
personIds,
offset,
pageSize,
);

if (!messageThreads) {
return {
totalNumberOfThreads: 0,
timelineThreads: [],
};
}

const messageThreadIds = messageThreads.map(
(messageThread) => messageThread.id,
);

const threadParticipantsByThreadId =
await this.timelineMessagingService.getThreadParticipantsByThreadId(
messageThreadIds,
);

const threadVisibilityByThreadId =
await this.timelineMessagingService.getThreadVisibilityByThreadId(
messageThreadIds,
workspaceMemberId,
);

return {
totalNumberOfThreads,
timelineThreads: formatThreads(
messageThreads,
threadParticipantsByThreadId,
threadVisibilityByThreadId,
),
};
}

async getMessagesFromCompanyId(
workspaceMemberId: string,
companyId: string,
page = 1,
pageSize: number = TIMELINE_THREADS_DEFAULT_PAGE_SIZE,
): Promise<TimelineThreadsWithTotal> {
const personRepository =
await this.twentyORMManager.getRepository<PersonWorkspaceEntity>(
'person',
);
const personIds = (
await personRepository.find({
where: {
companyId,
},
select: {
id: true,
},
})
).map((person) => person.id);

if (personIds.length === 0) {
return {
totalNumberOfThreads: 0,
timelineThreads: [],
};
}

const messageThreads = await this.getMessagesFromPersonIds(
workspaceMemberId,
personIds,
page,
pageSize,
);

return messageThreads;
}
}
Loading

0 comments on commit ffe3661

Please sign in to comment.