Skip to content

Commit

Permalink
remove listener url and it's data
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanelnajjar committed Sep 18, 2023
1 parent fdaa2e6 commit 4450834
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 29 deletions.
2 changes: 0 additions & 2 deletions web/database/users/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ DROP TABLE IF EXISTS users;
CREATE TABLE IF NOT EXISTS users (
"id" SERIAL PRIMARY KEY,
user_id TEXT NOT NULL UNIQUE,
listener_url TEXT,
shop TEXT,
name TEXT,
status BOOLEAN NOT NULL DEFAULT FALSE,
"created_at" TIMESTAMP NOT NULL DEFAULT NOW(),
Expand Down
4 changes: 0 additions & 4 deletions web/frontend/pages/HubUsers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ export default function HubUsers() {
<strong>User Id:</strong>
{user.userId}
</p>
<p>
<strong>Listener URL:</strong>
{user.listenerUrl}
</p>
</div>

<Button
Expand Down
13 changes: 3 additions & 10 deletions web/middleware/checkUserAccessPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ const clientSecret = process.env.OIDC_CLIENT_SECRET;
const issuerURL = process.env.OIDC_ISSUER;

const checkUserAccessPermissions = async (req, res, next) => {
const {
userId,
accessToken,
shop: hubShopName = '',
listenerUrl = ''
} = req.body;

console.log('req.body--- from check user access permission :::', req.body);
const { userId, accessToken } = req.body;

if (!userId) {
return res.status(403).json({
Expand Down Expand Up @@ -48,8 +41,8 @@ const checkUserAccessPermissions = async (req, res, next) => {
if (!user || user.rows.length === 0) {
// insert this user into the database with status false
await query(
'INSERT INTO users (user_id, status, name, shop, listener_url) VALUES ($1,$2,$3,$4,$5)',
[userId, false, userName, hubShopName, listenerUrl]
'INSERT INTO users (user_id, status, name) VALUES ($1,$2,$3)',
[userId, false, userName]
);

return res.status(403).json({
Expand Down
13 changes: 0 additions & 13 deletions web/webhooks/product-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ export const productUpdateListener = async (product, webhookId, topic) => {
return 'Webhook already exists';
}

// const sql = 'SELECT * from users WHERE status = true';
// const result = await query(sql);
// const listeners = result.rows;
// const promises = listeners.map(async (listener) => {
// const { shop: listenerShop, listenerUrl } = listener;
// await axios.post(listenerUrl, {
// shopName: listenerShop,
// product
// });
// });

// await Promise.allSettled(promises);

const insertWebhookQuery =
'INSERT INTO webhooks (id, topic, data) VALUES ($1, $2, $3)';

Expand Down

0 comments on commit 4450834

Please sign in to comment.