cron_notifications

This commit is contained in:
CHIEFSOFT\ameye
2023-12-07 20:27:00 -05:00
parent 6ded64be76
commit 5ed0ca0d31
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -111,6 +111,7 @@ long NotificationSystem(CVars in, CVars &out){
long limit = in["limit"].Long();
logfmt(logINFO, "ENTER NotificationSystem()");
long push_ret = -1;
long status = 0;
const PGresult *res = pgsql_query("SELECT count(member_uid) AS mcount,member_uid "
" FROM members_notification WHERE status=1 GROUP BY member_uid LIMIT %lu",limit);
if (res != NULL && pgsql_num_rows(res) > 0) {
@@ -123,6 +124,9 @@ long NotificationSystem(CVars in, CVars &out){
if ( load_db_record(out, "SELECT id AS notification_id, uid,member_uid,msg FROM members_notification "
" WHERE status =1 AND member_uid = '%s' ORDER BY id DESC LIMIT 1", rec["member_uid"].c_str())> 0){
pgsql_query("UPDATE members_notification SET status=2 "
" WHERE id = %lu", status,out["notification_id"].Long()); // move the status so no retry
CVars xx;
xx["member_uid"] = out["member_uid"]; xx["member_uid"].set_valid( true );
xx["push_text"] = out["msg"]; xx["push_text"].set_valid( true );
@@ -130,13 +134,15 @@ long NotificationSystem(CVars in, CVars &out){
if (push_ret == PHP_API_OK){
xx["send_result"] = "COMPLETED"; xx["send_result"].set_valid( true );
status = 5;
}
else
{
xx["send_result"] = "FAIL"; xx["send_result"].set_valid( true );
status = 7;
}
pgsql_query("UPDATE members_notification SET send=now(), send_result='%s' "
" WHERE id = %lu", out["notification_id"].Long(),xx["send_result"].c_str());
pgsql_query("UPDATE members_notification SET send=now(), send_result='%s', status=%lu "
" WHERE id = %lu",xx["send_result"].c_str(), status,out["notification_id"].Long());
}
} // for loopp
} // main nserach
+1 -1
View File
@@ -226,7 +226,7 @@ $routes->post('/en/wrench/api/v1/cron', 'WrenchCrons::apigate');
$routes->get('/en/wrench/api/v1/cron', 'WrenchCrons::apigate');
$routes->get('/en/wrench/api/v1/cron_jobalerts', 'WrenchCrons::jobalerts');
$routes->get('/en/wrench/api/v1/cron_notifications', 'WrenchCrons::notifications');
$routes->get('/en/wrench/api/v1/notifications', 'WrenchCrons::cron_notifications');
$routes->get('/en/wrench/api/v1/offersreminders', 'WrenchCrons::offersreminders');