Skip to content

Commit 7b49403

Browse files
committed
fix: unassign on escalate
1 parent 64ccf71 commit 7b49403

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/server/api/schema.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ const rootMutations = {
13971397
const [deleteResult, insertResult] = await Promise.all([
13981398
await r
13991399
.knex("campaign_contact_tag")
1400-
.where({ campaign_contact_id: campaignContactId })
1400+
.where({ campaign_contact_id: parseInt(campaignContactId) })
14011401
.whereIn("tag_id", removedTagIds)
14021402
.del(),
14031403
await r.knex("campaign_contact_tag").insert(tagsToInsert)
@@ -1427,6 +1427,20 @@ const rootMutations = {
14271427
.then(urls => urls.filter(url => url.length > 0));
14281428
await notifyOnTagConversation(campaignContactId, user.id, webhookUrls);
14291429

1430+
// See if any of the newly applied tags are is_assignable = false
1431+
const newlyAssignedTagsThatShouldUnassign = await r
1432+
.knex("tag")
1433+
.select("id")
1434+
.whereIn("id", addedTagIds)
1435+
.where({ is_assignable: false });
1436+
1437+
if (newlyAssignedTagsThatShouldUnassign.length > 0) {
1438+
await r
1439+
.knex("campaign_contact")
1440+
.update({ assignment_id: null })
1441+
.where({ id: parseInt(campaignContactId) });
1442+
}
1443+
14301444
return campaignContact;
14311445
},
14321446
createOptOut: async (
@@ -1901,6 +1915,8 @@ const rootMutations = {
19011915
contactsFilter
19021916
);
19031917

1918+
console.log(campaignContactIdsToMessageIds);
1919+
19041920
if (newTexterUserIds == null) {
19051921
const campaignContactIdsToUnassign = campaignContactIdsToMessageIds.map(
19061922
([ccId, _]) => ccId

0 commit comments

Comments
 (0)