From cfd1cced245779305fd99ef763993eb53aa1c1c0 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Thu, 12 Sep 2024 14:30:20 -0400 Subject: [PATCH] raw_contacts --- wrenchboard/src/include/wrenchboard_api.h | 2 + wrenchboard/src/shared_tool/account.cc | 37 +++++++++++ www-api/app/Config/Constants.php | 2 + www-api/app/Config/RoutesV1.php | 2 +- .../app/Controllers/WrenchUserContacts.php | 65 +++++++++++++++++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 www-api/app/Controllers/WrenchUserContacts.php diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index 31ed8bef..d6be264d 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -281,6 +281,8 @@ enum { PARTNER_STRIPE }; #define WRENCHBOARD_ACCOUNT_NOTIFICATIONS 11205 #define WRENCHBOARD_ACCOUNT_DASHRECENT 11206 +#define WRENCHBOARD_ACCOUNT_CONTACTIMPORT 11207 + #define WRENCHBOARD_RESOURCE_MYFILES 11307 #define WRENCHBOARD_MYFILES_LIST 11309 diff --git a/wrenchboard/src/shared_tool/account.cc b/wrenchboard/src/shared_tool/account.cc index 630ea86f..80b407cb 100644 --- a/wrenchboard/src/shared_tool/account.cc +++ b/wrenchboard/src/shared_tool/account.cc @@ -128,6 +128,7 @@ long test() { return 0L; } long WrenchTestWalletCapability(CVars in, CVars &out); +long WrenchImportContacts(CVars in, CVars &out); long account_calls(CVars in, CVars &out) { logfmt(logINFO, "account_calls()"); @@ -489,6 +490,11 @@ long account_calls(CVars in, CVars &out) { return WrenchRecentDash(in, out); break; + case WRENCHBOARD_ACCOUNT_CONTACTIMPORT: + // Contact imports + return WrenchImportContacts(in, out); + break; + case WRENCHBOARD_RESOURCE_MYFILES: return WrenchRegisterMyFileUpload(in, out); break; @@ -521,6 +527,37 @@ long account_calls(CVars in, CVars &out) { #define PHP_API_TRANSFER_COMPLETE 200 + +long WrenchImportContacts(CVars in, CVars &out) { + long ret = PHP_API_BAD_PARAM; + logfmt(logINFO, "long WrenchImportContacts(CVars in, CVars out)"); + REQ_STRING(in, "raw_contacts", 0, 5500, "(.*)"); + long member_id = REQ_LONG(in, "member_id", 1, -1); + REQ_STRING(in, "member_uid", 20, 100, "(.*)"); + CVars x; + const PGresult *res = pgsql_query("SELECT id AS import_id FROM members_contacts_import WHERE member_id=%lu", member_id); + if (res != NULL && pgsql_num_rows(res) > 0) { + mapf = pgsql_fetch_assoc(res, 0); + CVars rec; + map_to_cvars(f, rec); + + x["raw_contacts"] = in["raw_contacts"]; + x["raw_contacts"].set_valid(true); + update_db_record(DBS_VALID, "members_contacts_import", x, rec["import_id"].Long()); + ret = PHP_API_OK; + } else { + x["member_id"] = member_id; + x["member_id"].set_valid(true); + x["member_uid"] = member_uid; + x["member_uid"].set_valid(true); + x["raw_contacts"] = in["description"]; + x["raw_contacts"].set_valid(true); + long sid = insert_db_record(DBS_VALID, "members_contacts_import", "members_contacts_import_id_seq", x); + ret = PHP_API_OK; + } + return ret; +} + long WrenchMyPage(CVars in, CVars &out) { logfmt(logINFO, "WrenchMyPageIntro()"); long ret = PHP_API_BAD_PARAM; diff --git a/www-api/app/Config/Constants.php b/www-api/app/Config/Constants.php index e6a40f31..70f79c7d 100644 --- a/www-api/app/Config/Constants.php +++ b/www-api/app/Config/Constants.php @@ -280,6 +280,8 @@ const WRENCHBOARD_FAMILY_HOMEBANNERS = 11203; define('WRENCHBOARD_ACCOUNT_NOTIFICATIONS', 11205); +const WRENCHBOARD_ACCOUNT_CONTACTIMPORT = 11207; + const WRENCHBOARD_PICTURE_PROFILE = 11300; const WRENCHBOARD_PICTURE_JOB = 11303; const WRENCHBOARD_PICTURE_FAMBANNER= 11304; diff --git a/www-api/app/Config/RoutesV1.php b/www-api/app/Config/RoutesV1.php index 63c2a050..6e77311e 100644 --- a/www-api/app/Config/RoutesV1.php +++ b/www-api/app/Config/RoutesV1.php @@ -57,7 +57,7 @@ $routes->post('/en/wrench/api/v1/paymenthx', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/purchasehx', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/contracthx', 'WrenchJobs::contractHx'); -$routes->post('/en/wrench/api/v1/cachecontacts', 'WrenchApi::apigate'); +$routes->post('/en/wrench/api/v1/WrenchUserContacts', 'WrenchApi::usersContacts'); $routes->post('/en/wrench/api/v1/stepresetpass', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchUserContacts.php b/www-api/app/Controllers/WrenchUserContacts.php new file mode 100644 index 00000000..e0385ac1 --- /dev/null +++ b/www-api/app/Controllers/WrenchUserContacts.php @@ -0,0 +1,65 @@ +wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + log_message('critical', "usersBanners ********* ALL ".serialize($out) ); + + return $this->summaryReturnData($in,$out); //json_encode( $final_out ); + } + + private function processContacts( $in ){ + log_message('critical', "************************ cachecontacts 0001 ".serialize($in)); + + $inx =[]; + $inx["member_id"] = $in["member_id"]; + $inx["uid"] = $in["uid"]; + $inx["sessionid"] = $in["sessionid"]; + $raw_contacts = $in["raw_contacts"]; + + foreach ( $raw_contacts["contacts"] as $rows){ + $firstname = $rows["name"]["given"]; + $lastname = $rows["name"]["family"]; + $contactid = $rows["contactId"]; + log_message('critical', "************************ $firstname $lastname $contactid"); + } + } + + + +} \ No newline at end of file