diff --git a/import.sql b/import.sql index 5fe3b14..97f6b72 100644 --- a/import.sql +++ b/import.sql @@ -63,7 +63,7 @@ CREATE TABLE IF NOT EXISTS npwd_notes ( PRIMARY KEY (id) ); -CREATE TABLE IF NOT EXISTS npwd_sellout_listings ( +CREATE TABLE IF NOT EXISTS npwd_marketplace_listings ( id int(11) NOT NULL AUTO_INCREMENT, identifier varchar(255) DEFAULT NULL, username varchar(255) DEFAULT NULL, @@ -75,12 +75,6 @@ CREATE TABLE IF NOT EXISTS npwd_sellout_listings ( createdAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updatedAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id) -) -ENGINE = INNODB, -AUTO_INCREMENT = 31, -AVG_ROW_LENGTH = 2048, -CHARACTER SET utf8mb4, -COLLATE utf8mb4_general_ci; ); CREATE TABLE IF NOT EXISTS npwd_marketplace_reports ( @@ -88,10 +82,7 @@ CREATE TABLE IF NOT EXISTS npwd_marketplace_reports ( listing_id int(11) DEFAULT NULL, profile varchar(255) DEFAULT NULL, PRIMARY KEY (id) -) -ENGINE = INNODB, -CHARACTER SET utf8mb4, -COLLATE utf8mb4_general_ci; +); CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` ( `id` int NOT NULL AUTO_INCREMENT, diff --git a/resources/server/sv_sellout.ts b/resources/server/sv_sellout.ts index b6c8e45..0246fe5 100644 --- a/resources/server/sv_sellout.ts +++ b/resources/server/sv_sellout.ts @@ -1,5 +1,6 @@ import events from '../utils/events'; import { getIdentifier, getPlayer, getSource } from './functions'; +import { ESX } from './server'; import { pool } from './db'; import { mainLogger } from './sv_logger'; import { MarketplaceListing } from '../../typings/marketplace'; @@ -8,12 +9,10 @@ import { reportListingToDiscord } from './discord'; const selloutLogger = mainLogger.child({ module: 'sellout' }); async function fetchAllListings(): Promise { - const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC'; + const query = 'SELECT * FROM npwd_marketplace_listings ORDER BY id DESC'; const [results] = await pool.query(query); - const listings = results; - - return listings; + return results; } async function addListing( @@ -24,7 +23,7 @@ async function addListing( listing: MarketplaceListing, ): Promise { const query = - 'INSERT INTO npwd_sellout_listings (identifier, username, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?, ?)'; + 'INSERT INTO npwd_marketplace_listings (identifier, username, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?, ?)'; await pool.query(query, [ identifier, username, @@ -37,17 +36,16 @@ async function addListing( } async function deleteListing(listingId: number, identifier: string): Promise { - const query = 'DELETE FROM npwd_sellout_listings WHERE id = ? AND identifier = ?'; + const query = 'DELETE FROM npwd_marketplace_listings WHERE id = ? AND identifier = ?'; await pool.query(query, [listingId, identifier]); } async function getListing(listingId: number): Promise { - const query = `SELECT * FROM npwd_sellout_listings WHERE id = ?`; + const query = `SELECT * FROM npwd_marketplace_listings WHERE id = ?`; const [results] = await pool.query(query, [listingId]); const listings = results; - const listing = listings[0]; - return listing; + return listings[0]; } async function reportListing(listingId: number, profile: string): Promise { @@ -144,18 +142,19 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => { if (reportExists) { // send an info alert selloutLogger.error(`This listing has already been reported`); - emitNet(events.SELLOUT_ACTION_RESULT, pSource, { + return emitNet(events.SELLOUT_ACTION_RESULT, pSource, { message: 'MARKETPLACE_REPORT_LISTING_FAILED', type: 'info', }); - } else { - await reportListing(rListing.id, rListing.name); - await reportListingToDiscord(rListing, reportingPlayer); - emitNet(events.SELLOUT_ACTION_RESULT, pSource, { - message: 'MARKETPLACE_REPORT_LISTING_SUCCESS', - type: 'success', - }); } + + await reportListing(rListing.id, rListing.name); + await reportListingToDiscord(rListing, reportingPlayer); + + emitNet(events.SELLOUT_ACTION_RESULT, pSource, { + message: 'MARKETPLACE_REPORT_LISTING_SUCCESS', + type: 'success', + }); } catch (e) { selloutLogger.error(`Failed to report listing ${e.message}`, { source: pSource,