TASK22057: phase19 endpoint consistency hardening slice
This commit is contained in:
@@ -86,12 +86,30 @@ const recordExists = async (incidentId, contactId, token) => {
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const token = await getToken();
|
||||
const data = req.body;
|
||||
const watchedCaseBind = data?.["pinswg_WatchedCase@odata.bind"];
|
||||
const contactBind = data?.["pinswg_Contact@odata.bind"];
|
||||
|
||||
const incidentId =
|
||||
data["pinswg_WatchedCase@odata.bind"].match(/\(([^)]+)\)/)[1];
|
||||
const contactId = data["pinswg_Contact@odata.bind"].match(/\(([^)]+)\)/)[1];
|
||||
if (
|
||||
typeof watchedCaseBind !== "string" ||
|
||||
watchedCaseBind.length === 0 ||
|
||||
typeof contactBind !== "string" ||
|
||||
contactBind.length === 0
|
||||
) {
|
||||
return res.status(400).json();
|
||||
}
|
||||
|
||||
const watchedCaseMatch = watchedCaseBind.match(/\(([^)]+)\)/);
|
||||
const contactMatch = contactBind.match(/\(([^)]+)\)/);
|
||||
|
||||
if (!watchedCaseMatch || !contactMatch) {
|
||||
return res.status(400).json();
|
||||
}
|
||||
|
||||
const token = await getToken();
|
||||
|
||||
const incidentId = watchedCaseMatch[1];
|
||||
const contactId = contactMatch[1];
|
||||
|
||||
const existingRecord = await recordExists(incidentId, contactId, token);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user