Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server, web): Include partner's photos on map #7065

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/src/domain/asset/asset.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ describe(AssetService.name, () => {

describe('getMapMarkers', () => {
it('should get geo information of assets', async () => {
partnerMock.getAll.mockResolvedValue([]);
assetMock.getMapMarkers.mockResolvedValue(
[assetStub.withLocation].map((asset) => ({
id: asset.id,
Expand Down
15 changes: 13 additions & 2 deletions server/src/domain/asset/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,19 @@ export class AssetService {
return folder;
}

getMapMarkers(auth: AuthDto, options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
return this.assetRepository.getMapMarkers(auth.user.id, options);
async getMapMarkers(auth: AuthDto, options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
const userIds: string[] = [auth.user.id];
if (1) {
ttyridal marked this conversation as resolved.
Show resolved Hide resolved
const partners = await this.partnerRepository.getAll(auth.user.id);
const partnersIds = partners
.filter(
(partner) =>
partner.sharedBy && partner.sharedWith && partner.sharedById != auth.user.id && partner.inTimeline,
)
.map((partner) => partner.sharedById);
userIds.push(...partnersIds);
}
return this.assetRepository.getMapMarkers(userIds, options);
}

async getMemoryLane(auth: AuthDto, dto: MemoryLaneDto): Promise<MemoryLaneResponseDto[]> {
Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export interface IAssetRepository {
softDeleteAll(ids: string[]): Promise<void>;
restoreAll(ids: string[]): Promise<void>;
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null>;
getMapMarkers(ownerId: string, options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
getMapMarkers(ownerIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
getStatistics(ownerId: string, options: AssetStatsOptions): Promise<AssetStats>;
getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]>;
getTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]>;
Expand Down
4 changes: 2 additions & 2 deletions server/src/infra/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export class AssetRepository implements IAssetRepository {
});
}

async getMapMarkers(ownerId: string, options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> {
async getMapMarkers(ownerIds: string[], options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> {
const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options;

const assets = await this.repository.find({
Expand All @@ -645,7 +645,7 @@ export class AssetRepository implements IAssetRepository {
},
},
where: {
ownerId,
ownerId: In([...ownerIds]),
isVisible: true,
isArchived,
exifInfo: {
Expand Down