-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 11-restrict-creation
- Loading branch information
Showing
15 changed files
with
170 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ChtApi, PlacePayload } from '../lib/cht-api'; | ||
import Place from './place'; | ||
import { retryOnUpdateConflict } from '../lib/retry-logic'; | ||
import { Uploader } from './upload-manager'; | ||
|
||
export class UploadReplacementWithDeactivation implements Uploader { | ||
private readonly chtApi: ChtApi; | ||
|
||
constructor(chtApi: ChtApi) { | ||
this.chtApi = chtApi; | ||
} | ||
|
||
handleContact = async (payload: PlacePayload): Promise<string | undefined> => { | ||
return await this.chtApi.createContact(payload); | ||
}; | ||
|
||
handlePlacePayload = async (place: Place, payload: PlacePayload): Promise<string> => { | ||
const contactId = place.creationDetails?.contactId; | ||
const placeId = place.resolvedHierarchy[0]?.id; | ||
|
||
if (!contactId || !placeId) { | ||
throw Error('contactId and placeId are required'); | ||
} | ||
|
||
const updatedPlaceDoc = await retryOnUpdateConflict<any>(() => this.chtApi.updatePlace(payload, contactId)); | ||
await this.chtApi.deactivateUsersWithPlace(placeId); | ||
return updatedPlaceDoc._id; | ||
}; | ||
|
||
linkContactAndPlace = async (place: Place, placeId: string): Promise<void> => { | ||
const contactId = await this.chtApi.updateContactParent(placeId); | ||
place.creationDetails.contactId = contactId; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.