|
|
|
@@ -22,7 +22,7 @@ long SignUpPendingReminder(CVars in, CVars &out);
|
|
|
|
|
long SignUpStats(CVars in, CVars &out);
|
|
|
|
|
long PastDueWarings(CVars in, CVars &out);
|
|
|
|
|
long PastDueOffersRefund(CVars in, CVars &out);
|
|
|
|
|
|
|
|
|
|
long NotificationSystem(CVars in, CVars &out);
|
|
|
|
|
long CronTracker(CVars in, CVars &out);
|
|
|
|
|
/*
|
|
|
|
|
CREATE TABLE cron_jobs (
|
|
|
|
@@ -90,12 +90,66 @@ long sitecrons_calls(CVars in, CVars &out) {
|
|
|
|
|
return OfferPending(in, out);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WRB_CRONJOB_NOTIFICATIONS:
|
|
|
|
|
ct["job_type"]="WRB_CRONJOB_PENDOFFER_ALERT"; ct["job_type"].set_valid( true );
|
|
|
|
|
ct["description"]="Offer is pending remind the client to attend to it before it expires "; ct["description"].set_valid( true );
|
|
|
|
|
CronTracker(ct, co);
|
|
|
|
|
return NotificationSystem(in, out);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logfmt(logINFO, "/sitecrons_calls()");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long NotificationSystem(CVars in, CVars &out){
|
|
|
|
|
long ret = 0;
|
|
|
|
|
const PGresult *res;
|
|
|
|
|
long limit = in["one_limit"].Long();
|
|
|
|
|
logfmt(logINFO, "ENTER NotificationSystem()");
|
|
|
|
|
long contract_id = 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) {
|
|
|
|
|
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
|
|
|
|
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
|
|
|
|
if (f.empty()) continue;
|
|
|
|
|
CVars rec;
|
|
|
|
|
map_to_cvars(f, rec);
|
|
|
|
|
/*
|
|
|
|
|
wrenchboard=> SELECT uid,member_uid,msg FROM members_notification WHERE status =1 AND member_uid = '7b66905e-b2c4-4ae3-9b32-83aa50d4d0f5' ORDER BY id DESC LIMIT 1;
|
|
|
|
|
uid | member_uid | msg
|
|
|
|
|
--------------------------------------+--------------------------------------+---------------------------------------------------------
|
|
|
|
|
40a675fc-8073-4fb7-8b81-2fa699779e54 | 7b66905e-b2c4-4ae3-9b32-83aa50d4d0f5 | You have received a new offer waiting for you to start!
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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){
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
long push_ret = BkoSendPush( xx, out);
|
|
|
|
|
|
|
|
|
|
if (push_ret == PHP_API_OK){
|
|
|
|
|
xx["send_result"] = "COMPLETED"; xx["send_result"].set_valid( true );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
xx["send_result"] = "FAIL"; xx["send_result"].set_valid( true );
|
|
|
|
|
}
|
|
|
|
|
pgsql_query("UPDATE members_notification SET send=now(), send_result='%s' WHERE id = %lu", out["notification_id"].Long(),xx["send_result"].c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long CronTracker(CVars in, CVars &out){
|
|
|
|
|
long ret = 0;
|
|
|
|
|
const PGresult *res;
|
|
|
|
|