rbs@u2
Home
Php_u2
Html #1
Html #2
Html #3
Html #4
JS #1
JS #2
JS #3
JS #4
JsApi #1
JsApi #2
JsApi #3
JsApi #4
JsApi_u4
all-files
ori-v2
master
user
Logout
dsg
tool css
bootstrtap 5.3
auth
profile
waste
waste_group
venue
vehicle
event
comment
notification
discover
post
scanner
to_delete
const fetch = require('node-fetch'); async function auth(v) { let url=`${v.api}/notification/bulk-notifications-read/${v.param}`; console.log(url) const res = await fetch(url,{ method: 'POST', body: JSON.stringify(v.body), headers: { 'Content-Type': 'application/json', } }); return res } async function auth(v) { let url=`${v.api}/notification/get-new-notifications-count/${v.param}`; console.log(url) const res = await fetch(url,{ method: 'POST', body: JSON.stringify(v.body), headers: { 'Content-Type': 'application/json', } }); return res } async function auth(v) { let url=`${v.api}/notification/get-notifications/${v.param}`; console.log(url) const res = await fetch(url,{ method: 'POST', body: JSON.stringify(v.body), headers: { 'Content-Type': 'application/json', } }); return res } const notification = { auth, auth, auth, } module.exports = notification
Save
user_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)>0) { //terbaru //24jam yl= now=time(), sejam ygl= now-86400 $t_24hours=time()-86400; $sql2=$sql." and create_at>".$t_24hours." order by create_at desc"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)>0) { $b=0; while($r2=mysqli_fetch_assoc($res2)) { $dt['data']['recent'][$b]['_id'] =$r2['id']; $dt['data']['recent'][$b]['date']=$r2['date']; $dt['data']['recent'][$b]['is_read'] =$r2['is_read']; $dt['data']['recent'][$b]['type'] =$r2['type']; $dt['data']['recent'][$b]['entity']['user_id']=$r2['entity_from_user_id']; $dt['data']['recent'][$b]['entity']['entity_id']=$r2['entity_id']; $dt['data']['recent'][$b]['entity']['entity_type']=$r2['entity_type']; $dt['data']['recent'][$b]['entity']['entity_data']=[]; $dt['data']['recent'][$b]['entity']['initiator_data']['id']=$r2['entity_from_user_id']; $sql2b="SELECT name,profile_image,username from `users` where id=".$r2['entity_from_user_id']; $res2b=mysqli_query($db,$sql2b); if(mysqli_num_rows($res2b)>0) { $r2b=mysqli_fetch_assoc($res2b); $dt['data']['recent'][$b]['entity']['initiator_data']['display_name']=$r2b['name']; $dt['data']['recent'][$b]['entity']['initiator_data']['profile_image']=$r2b['profile_image']; } $b++; } } else { $dt['data']['recent']=[]; } //last week $t_30days_last=time()-(86400*30); $sql4=$sql." and create_at<".$t_7days_last." and create_at>".$t_30days_last." order by create_at desc"; $res4=mysqli_query($db,$sql4); if(mysqli_num_rows($res4)>0) { $b=0; while($r3=mysqli_fetch_assoc($res4)) { $dt['data']['last_30_days'][$b]['_id'] =$r4['id']; $dt['data']['last_30_days'][$b]['date'] =$r4['date']; $dt['data']['last_30_days'][$b]['is_read'] =$r4['is_read']; $dt['data']['last_30_days'][$b]['type'] =$r4['type']; $dt['data']['last_30_days'][$b]['entity']['user_id'] =$r4['entity_from_user_id']; $dt['data']['last_30_days'][$b]['entity']['entity_id'] =$r4['entity_id']; $dt['data']['last_30_days'][$b]['entity']['entity_type']=$r4['entity_type']; $dt['data']['last_30_days'][$b]['entity']['entity_data']=[]; $dt['data']['last_30_days'][$b]['entity']['initiator_data']['id']=$r4['entity_from_user_id']; $sql4b="SELECT name,profile_image,username from `users` where id=".$r4['entity_from_user_id']; $res4b=mysqli_query($db,$sql4b); if(mysqli_num_rows($res4b)>0) { $r4b=mysqli_fetch_assoc($res4b); $dt['data']['last_30_days'][$b]['entity']['initiator_data']['display_name']=$r4b['name']; $dt['data']['last_30_days'][$b]['entity']['initiator_data']['profile_image']=$r4b['profile_image']; } $b++; } } else { $dt['data']['last_30_days']=[]; } // last 30 days $dt['success']=true; } else { $dt['success']=false; $dt['data']=[]; } return $dt; } ?>
user_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); $dt['count']=mysqli_num_rows($res); $dt['success']=true; return $dt; } function get_notifications($js){ global $ar,$db; $dt=array(); //{"user_id":67032} $sql="SELECT * from `notifications` where for_user_id=".$js->user_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)>0) { //terbaru //24jam yl= now=time(), sejam ygl= now-86400 $t_24hours=time()-86400; $sql2=$sql." and create_at>".$t_24hours." order by create_at desc"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)>0) { $b=0; while($r2=mysqli_fetch_assoc($res2)) { $dt['data']['recent'][$b]['_id'] =$r2['id']; $dt['data']['recent'][$b]['date']=$r2['date']; $dt['data']['recent'][$b]['is_read'] =$r2['is_read']; $dt['data']['recent'][$b]['type'] =$r2['type']; $dt['data']['recent'][$b]['entity']['user_id']=$r2['entity_from_user_id']; $dt['data']['recent'][$b]['entity']['entity_id']=$r2['entity_id']; $dt['data']['recent'][$b]['entity']['entity_type']=$r2['entity_type']; $dt['data']['recent'][$b]['entity']['entity_data']=[]; $dt['data']['recent'][$b]['entity']['initiator_data']['id']=$r2['entity_from_user_id']; $sql2b="SELECT name,profile_image,username from `users` where id=".$r2['entity_from_user_id']; $res2b=mysqli_query($db,$sql2b); if(mysqli_num_rows($res2b)>0) { $r2b=mysqli_fetch_assoc($res2b); $dt['data']['recent'][$b]['entity']['initiator_data']['display_name']=$r2b['name']; $dt['data']['recent'][$b]['entity']['initiator_data']['profile_image']=$r2b['profile_image']; } $b++; } } else { $dt['data']['recent']=[]; } //last week $t_30days_last=time()-(86400*30); $sql4=$sql." and create_at<".$t_7days_last." and create_at>".$t_30days_last." order by create_at desc"; $res4=mysqli_query($db,$sql4); if(mysqli_num_rows($res4)>0) { $b=0; while($r3=mysqli_fetch_assoc($res4)) { $dt['data']['last_30_days'][$b]['_id'] =$r4['id']; $dt['data']['last_30_days'][$b]['date'] =$r4['date']; $dt['data']['last_30_days'][$b]['is_read'] =$r4['is_read']; $dt['data']['last_30_days'][$b]['type'] =$r4['type']; $dt['data']['last_30_days'][$b]['entity']['user_id'] =$r4['entity_from_user_id']; $dt['data']['last_30_days'][$b]['entity']['entity_id'] =$r4['entity_id']; $dt['data']['last_30_days'][$b]['entity']['entity_type']=$r4['entity_type']; $dt['data']['last_30_days'][$b]['entity']['entity_data']=[]; $dt['data']['last_30_days'][$b]['entity']['initiator_data']['id']=$r4['entity_from_user_id']; $sql4b="SELECT name,profile_image,username from `users` where id=".$r4['entity_from_user_id']; $res4b=mysqli_query($db,$sql4b); if(mysqli_num_rows($res4b)>0) { $r4b=mysqli_fetch_assoc($res4b); $dt['data']['last_30_days'][$b]['entity']['initiator_data']['display_name']=$r4b['name']; $dt['data']['last_30_days'][$b]['entity']['initiator_data']['profile_image']=$r4b['profile_image']; } $b++; } } else { $dt['data']['last_30_days']=[]; } // last 30 days $dt['success']=true; } else { $dt['success']=false; $dt['data']=[]; } return $dt; } ?>
Save
export const markMultipleNotificationsAsRead = async (notificationIds) => { const user = await getSessionUser(); if (!user) return null; const response = await fetch(`${API_URL}/wp-json/app/v1/bulk-notifications-read`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }); const data = await response.json(); return data; }; export const getNotificationCount = async () => { const user = await getSessionUser() if (!user || !user.id) return const response = await fetch(`${API_URL}/wp-json/app/v1/get-new-notifications-count`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }); const data = await response.json(); return data; } export const getUserNotifications = async () => { try { const user = await getSessionUser() if (!user) { throw new Error('Session user not found') } const response = await fetch(`${API_URL}/wp-json/app/v1/get-notifications`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }) const data = await response.json() return data } catch (error) { console.error('Error fetching user notifications:', error) return null } }
import { API_URL, TIMEOUT_MS_HIGHER } from "./consts.js" import { getSessionUser } from "./auth.js"; export const markMultipleNotificationsAsRead = async (notificationIds) => { const user = await getSessionUser(); if (!user) return null; const response = await fetch(`${API_URL}/wp-json/app/v1/bulk-notifications-read`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }); const data = await response.json(); return data; }; export const getNotificationCount = async () => { const user = await getSessionUser() if (!user || !user.id) return const response = await fetch(`${API_URL}/wp-json/app/v1/get-new-notifications-count`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }); const data = await response.json(); return data; }; export const getUserNotifications = async () => { try { const user = await getSessionUser() if (!user) { throw new Error('Session user not found') } const response = await fetch(`${API_URL}/wp-json/app/v1/get-notifications`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id }), }) const data = await response.json() return data } catch (error) { console.error('Error fetching user notifications:', error) return null } };
Save
notification
-- bulk-notifications-read
-- get-new-notifications-count
-- get-notifications