diff --git a/phone/src/apps/twitter/components/TwitterApp.js b/phone/src/apps/twitter/components/TwitterApp.js index 0a59c2a..7e96138 100644 --- a/phone/src/apps/twitter/components/TwitterApp.js +++ b/phone/src/apps/twitter/components/TwitterApp.js @@ -17,6 +17,7 @@ import TwitterSearch from "./TwitterSearch"; import "./twitter.css"; import "emoji-mart/css/emoji-mart.css"; +import { useProfile } from "../hooks/useProfile"; const useStyles = makeStyles(() => ({ backgroundModal: { @@ -37,6 +38,9 @@ export const TwitterApp = () => { const classes = useStyles(); const { modalVisible, setModalVisible } = useModal(); const [activePage, setActivePage] = useState(0); + const { profile } = useProfile(); + + console.log(profile); useEffect(() => { Nui.send("phone:getOrCreateTwitterProfile", {}); diff --git a/resources/config.lua b/resources/config.lua index d84f031..8867bf0 100644 --- a/resources/config.lua +++ b/resources/config.lua @@ -23,8 +23,7 @@ Config.DestroyPhoneReCheck = 3 --MINUTES /// WIll wait the check for x MINUTES a --Twitter ------ Config.twitter = {} --- Config.twitter.registerByName = true -- if users can register by first_name and last_name from the users table --- Config.twitter.registerByPhoneNumber = true -- if users can register by phone_number from the users table +Config.twitter.generateProfileNameFromUsers = true -- if the player's profile name should be generated from the users.first_name and users.last_name table Config.twitter.characterLimit = 240 -- character limit on tweet messages Config.twitter.allowEdtiableProfileName = true -- whether or not players can edit their profile names -- Config.twitter.enableLikes = true -- whether or not players can like other player's tweets and that they are visible diff --git a/resources/html/index.html b/resources/html/index.html index 9c511ba..d196fe9 100644 --- a/resources/html/index.html +++ b/resources/html/index.html @@ -1 +1,44 @@ -React App
\ No newline at end of file + + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/resources/import.sql b/resources/import.sql index cd8772c..506808c 100644 --- a/resources/import.sql +++ b/resources/import.sql @@ -23,7 +23,6 @@ CREATE TABLE `npwd_twitter_tweets` ( `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `likes` int NOT NULL DEFAULT '0', `identifier` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `realUser` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `visible` tinyint NOT NULL DEFAULT '1', `images` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '', PRIMARY KEY (`id`) diff --git a/resources/server/sv_twitter.lua b/resources/server/sv_twitter.lua index 7f14a3a..5ea0b7d 100644 --- a/resources/server/sv_twitter.lua +++ b/resources/server/sv_twitter.lua @@ -60,12 +60,11 @@ ESX.RegisterServerCallback('phone:createTweet', function(source, cb, data) local _identifier = xPlayer.getIdentifier() MySQL.Async.transaction({[[ - INSERT INTO npwd_twitter_tweets (`identifier`, `realUser`, `message`, `images`) - VALUES (@identifier, @realUser, @message, @images) + INSERT INTO npwd_twitter_tweets (`identifier`, `message`, `images`) + VALUES (@identifier, @message, @images) ]]}, { identifier = _identifier, - realUser = data.realUser, message = data.message, images = data.images }, @@ -86,28 +85,27 @@ function getProfile(identifier, cb) end function getProfileName(identifier, cb) - local defaultProfileName = '' -- handle any edge cases where the user does not exist or their name isn't populated + local defaultProfileName = '' + if Config.twitter.generateProfileNameFromUsers == false then + print('use default') + cb(defaultProfileName) + return + end + + -- TODO: make this query configurable MySQL.Async.fetchAll([[ - SELECT first_name, last_name + SELECT CONCAT(first_name, '_', last_name) AS profile_name FROM users WHERE identifier = @identifier LIMIT 1 ]], { identifier = identifier }, function(users) - -- no user found with this identifier - if next(users) == nil then - cb(defaultProfileName) - return - end - - local first_name = users[1].first_name - local last_name = users[1].last_name - if (first_name == "" and last_name == "") then + if next(users) == nil then -- no user found with this identifier cb(defaultProfileName) - else - local profileName = first_name .. '_' .. last_name - cb(profileName) + return end + + cb(users[1].profile_name) end) end