Skip to content

Commit

Permalink
Quick touchup
Browse files Browse the repository at this point in the history
  • Loading branch information
kennsippell committed Mar 12, 2024
1 parent 5a2177c commit 6a17c20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/lib/cht-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ export class ChtApi {
const payloadClone:any = _.cloneDeep(payload);
delete payloadClone.contact;
delete payloadClone.parent;
doc.previousPrimaryContacts = [
...(doc.previousPrimaryContacts || []),
doc.contact._id,
];

if (!doc.user_attribution) {
doc.user_attribution = {};
}
(doc.user_attribution.previousPrimaryContacts ||= []).push(doc.contact._id);
Object.assign(doc, payloadClone, { contact: { _id: contactId }});

const putUrl = `${this.protocolAndHost}/medic/${payload._id}`;
Expand Down
2 changes: 1 addition & 1 deletion src/services/place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class Place {

public asChtPayload(username: string): PlacePayload {
const user_attribution = {
tool: `cht_usr-${appVersion}`,
tool: `cht-user-management-${appVersion}`,
username,
created_time: Date.now(),
replacement: this.resolvedHierarchy[0],
Expand Down
4 changes: 3 additions & 1 deletion test/services/upload-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ async function createMocks() {
createContact: sinon.stub().resolves('replacement-contact-id'),
updatePlace: sinon.stub().resolves({
_id: 'updated-place-id',
previousPrimaryContacts: ['prev_contact_id'],
user_attribution: {
previousPrimaryContacts: ['prev_contact_id'],
},
}),
deleteDoc: sinon.stub().resolves(),
disableUsersWithPlace: sinon.stub().resolves(['org.couchdb.user:disabled']),
Expand Down

0 comments on commit 6a17c20

Please sign in to comment.