diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100755
index 0000000..fe4c17a
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx --no-install commitlint --edit ""
diff --git a/README.md b/README.md
index bb14a7d..fdc0f09 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
-NPWD is our flagship and current running project. Our team has been working on the project since August, 2020. This resource isn’t complete yet and currently has no ETA for release. Feel free to test it out in a dev environment by following the installation guide.
+NPWD is our flagship and current running project. The team has been working on the project since August, 2020. This resource isn’t complete yet and currently has no ETA for release. Feel free to test it out in a dev environment by following the installation guide.
Written completely by the Project Error Dev Team in [React](https://reactjs.org/) with a [TypeScript](https://www.typescriptlang.org/) client/server environment.
diff --git a/commitlint.config.js b/commitlint.config.js
new file mode 100644
index 0000000..84dcb12
--- /dev/null
+++ b/commitlint.config.js
@@ -0,0 +1,3 @@
+module.exports = {
+ extends: ['@commitlint/config-conventional'],
+};
diff --git a/config.json b/config.json
index 71bca44..18200fe 100644
--- a/config.json
+++ b/config.json
@@ -12,7 +12,12 @@
"vertical": "top"
},
"general": {
- "useDashNumber": true
+ "useDashNumber": true,
+ "enableMultiChar": false
+ },
+ "database": {
+ "playerTable": "users",
+ "identifierColumn": "identifier"
},
"twitter": {
"showNotifications": true,
diff --git a/fxmanifest.lua b/fxmanifest.lua
index d774a08..ecb0d05 100644
--- a/fxmanifest.lua
+++ b/fxmanifest.lua
@@ -3,8 +3,9 @@ game "gta5"
description 'js runtime monkaW'
authors { "itschip", "erik-sn", "TasoOneAsia", "kidz", "RockySouthpaw"}
-client_script {
- 'resources/dist/client/*.client.js'
+client_scripts {
+ 'resources/dist/client/*.client.js',
+ 'resources/client/*.lua'
}
server_script {
diff --git a/package.json b/package.json
index 8021990..0bb3c19 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,9 @@
"repository": "https://github.com/project-error/new-phone-who-dis",
"license": "CC-BY-NC-SA-4.0",
"devDependencies": {
+ "@commitlint/cli": "^12.1.1",
+ "@commitlint/config-conventional": "^12.1.1",
+ "@octokit/core": "^3.4.0",
"husky": "^5.1.3",
"lerna": "^3.22.1",
"prettier": "^2.2.1",
@@ -15,11 +18,11 @@
"prepare": "husky install",
"bootstrap": "lerna bootstrap",
"format:staged": "pretty-quick --staged",
- "postinstall": "husky install"
+ "postinstall": "husky install && yarn bootstrap"
},
"husky": {
"hooks": {
- "pre-commit": "npm run format:staged"
+ "pre-commit": "npx run format:staged"
}
}
}
diff --git a/phone/i18n.missingKeys.js b/phone/i18n.missingKeys.js
index 67f4600..6b8af8a 100644
--- a/phone/i18n.missingKeys.js
+++ b/phone/i18n.missingKeys.js
@@ -4,7 +4,7 @@ console.log(args);
const path = './src/locale/';
-const langs = ['bs', 'no', 'es', 'fr', 'pt', 'ptbr', 'sv', 'tr'];
+const langs = ['bs', 'no', 'es', 'fr', 'pt', 'ptbr', 'sv', 'tr', "hu"];
const defaultLang = 'en';
diff --git a/phone/package.json b/phone/package.json
index 59af494..0850fd1 100644
--- a/phone/package.json
+++ b/phone/package.json
@@ -6,10 +6,6 @@
"license": "CC-BY-NC-SA-4.0",
"homepage": "/resources/html",
"dependencies": {
- "@fortawesome/fontawesome-svg-core": "^1.2.35",
- "@fortawesome/free-brands-svg-icons": "^5.15.1",
- "@fortawesome/free-solid-svg-icons": "^5.15.1",
- "@fortawesome/react-fontawesome": "^0.1.14",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.56",
@@ -20,7 +16,7 @@
"dompurify": "^2.2.6",
"emoji-mart": "^3.0.1",
"enzyme": "^3.11.0",
- "fivem-nui-react-lib": "2.2.6",
+ "fivem-nui-react-lib": "^2.2.8",
"howler": "^2.2.1",
"i18next": "^19.7.0",
"jsonschema": "^1.4.0",
diff --git a/phone/src/Phone.test.tsx b/phone/src/Phone.test.tsx
index a08e424..8f94b70 100644
--- a/phone/src/Phone.test.tsx
+++ b/phone/src/Phone.test.tsx
@@ -1,12 +1,12 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import { shallow } from 'enzyme';
-import { PhoneContainer } from './PhoneContainer';
+import { PhoneProviders } from './PhoneProviders';
it('renders Phone', () => {
shallow(
-
+
,
);
});
diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index ad6a04b..baa5654 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -4,7 +4,7 @@ import './i18n';
import { Route } from 'react-router-dom';
import { CallModal } from './os/call/components/CallModal';
import { HomeApp } from './apps/home/components/Home';
-import { Box, Paper, Slide, Typography } from '@material-ui/core';
+import { Box, Paper, Typography } from '@material-ui/core';
import { NotificationBar } from './os/notifications/components/NotificationBar';
import { Navigation } from './os/navigation-bar/components/Navigation';
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
@@ -23,7 +23,6 @@ import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSet
import { useCallService } from './os/call/hooks/useCallService';
import { useDialService } from './apps/dialer/hooks/useDialService';
import InjectDebugData from './os/debug/InjectDebugData';
-import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
import { PhoneSnackbar } from './ui/components/PhoneSnackbar';
import { NotificationAlert } from './os/notifications/components/NotificationAlert';
import { useCallModal } from './os/call/hooks/useCallModal';
@@ -34,6 +33,7 @@ import { useSnackbar } from './ui/hooks/useSnackbar';
import { PhoneEvents } from '../../typings/phone';
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
+import PhoneWrapper from './PhoneWrapper';
import dayjs from 'dayjs';
import DefaultConfig from '../../config.json';
@@ -80,74 +80,45 @@ function Phone() {
useDialService();
const { modal: callModal } = useCallModal();
- const { bottom, visibility } = usePhoneVisibility();
const { isPhoneReady } = usePhone();
return (
-
-
-
-
-
- {isPhoneReady ? (
- <>
-
-
- <>
-
- {callModal &&
}
- {apps.map((App) => (
-
- ))}
- >
-
-
-
-
- >
- ) : (
-
-
- NPWD {t('INITIALIZING')}
-
- {t('GENERIC_WAIT')}
-
- )}
+
+ {isPhoneReady ? (
+ <>
+
+
+ <>
+
+ {callModal &&
}
+ {apps.map((App) => (
+
+ ))}
+ >
+
+
-
-
-
+
+ >
+ ) : (
+
+
+ NPWD {t('INITIALIZING')}
+
+ {t('GENERIC_WAIT')}
+
+ )}
+
);
}
diff --git a/phone/src/PhoneContainer.tsx b/phone/src/PhoneProviders.tsx
similarity index 95%
rename from phone/src/PhoneContainer.tsx
rename to phone/src/PhoneProviders.tsx
index db7c7cb..36424b4 100644
--- a/phone/src/PhoneContainer.tsx
+++ b/phone/src/PhoneProviders.tsx
@@ -7,7 +7,7 @@ import Phone from './Phone';
import { NuiProvider } from 'fivem-nui-react-lib';
import { SoundProvider } from './os/sound/providers/SoundProvider';
-export const PhoneContainer = () => {
+export const PhoneProviders = () => {
const currentTheme = usePhoneTheme();
return (
diff --git a/phone/src/PhoneWrapper.tsx b/phone/src/PhoneWrapper.tsx
new file mode 100644
index 0000000..d02d566
--- /dev/null
+++ b/phone/src/PhoneWrapper.tsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
+import { useSettings } from './apps/settings/hooks/useSettings';
+import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
+import { Slide } from '@material-ui/core';
+
+const PhoneWrapper: React.FC = ({ children }) => {
+ const [settings] = useSettings();
+ const { bottom, visibility } = usePhoneVisibility();
+
+ return (
+
+
+
+ );
+};
+
+export default PhoneWrapper;
diff --git a/phone/src/apps/bank/components/navigation/NavigationBar.tsx b/phone/src/apps/bank/components/navigation/NavigationBar.tsx
index 971367d..a28e17c 100644
--- a/phone/src/apps/bank/components/navigation/NavigationBar.tsx
+++ b/phone/src/apps/bank/components/navigation/NavigationBar.tsx
@@ -3,8 +3,7 @@ import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faHome, faList, faMoneyCheck } from '@fortawesome/free-solid-svg-icons';
+import { Home, List, Payment } from '@material-ui/icons';
const useStyles = makeStyles((theme) => ({
root: {
@@ -30,21 +29,9 @@ export const NavigationBar = () => {
showLabels
className={classes.root}
>
- }
- to="/bank"
- />
- }
- to="/bank/account"
- />
- }
- to="/bank/transactions"
- />
+ } to="/bank" />
+ } to="/bank/account" />
+ } to="/bank/transactions" />
);
};
diff --git a/phone/src/apps/contacts/components/views/ContactInfo.tsx b/phone/src/apps/contacts/components/views/ContactInfo.tsx
index 01dfbf0..8b8963b 100644
--- a/phone/src/apps/contacts/components/views/ContactInfo.tsx
+++ b/phone/src/apps/contacts/components/views/ContactInfo.tsx
@@ -51,9 +51,9 @@ const ContactsInfoPage = () => {
const Nui = useNuiRequest();
const classes = useStyles();
const history = useHistory();
-
+
const { getContact } = useContacts();
-
+
const { id } = useParams();
const { addNumber, referal } = useQueryParams({
referal: '/contacts',
@@ -109,9 +109,7 @@ const ContactsInfoPage = () => {
data: contact,
level: 2,
});
- Nui.send(ContactEvents.DELETE_CONTACT, {
- id: contact.id,
- });
+ Nui.send(ContactEvents.DELETE_CONTACT, contact.id);
history.goBack();
};
diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts
index 643211f..2e5beeb 100644
--- a/phone/src/apps/dialer/hooks/useDialService.ts
+++ b/phone/src/apps/dialer/hooks/useDialService.ts
@@ -2,8 +2,21 @@ import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from 'fivem-nui-react-lib';
import { dialState } from './state';
import { CallEvents } from '../../../../../typings/call';
+import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
+import { useTranslation } from 'react-i18next';
export const useDialService = () => {
+ const { addAlert } = useSnackbar();
+ const { t } = useTranslation();
+
+ const handleAddAlert = ({ message, type }: IAlert) => {
+ addAlert({
+ message: t(`APPS_${message}`),
+ type,
+ });
+ };
+
const setHistory = useSetRecoilState(dialState.history);
useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory);
+ useNuiEvent('DAILER', CallEvents.SEND_ALERT, handleAddAlert);
};
diff --git a/phone/src/apps/marketplace/components/MarketplaceApp.tsx b/phone/src/apps/marketplace/components/MarketplaceApp.tsx
index 536e2a1..cff692e 100644
--- a/phone/src/apps/marketplace/components/MarketplaceApp.tsx
+++ b/phone/src/apps/marketplace/components/MarketplaceApp.tsx
@@ -1,7 +1,6 @@
import React from 'react';
-import { AppWrapper } from '../../../ui/components/AppWrapper';
+import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
-import { MarketplaceTitle } from './MarketplaceTitle';
import { MarketplaceListContainer } from './SelloutList/MarketplaceListContainer';
import { NavigationBar } from './navigation/NavigationBar';
import { Switch, Route } from 'react-router-dom';
@@ -9,12 +8,16 @@ import { ListingFormContainer } from './form/ListingFormContainer';
import InjectDebugData from '../../../os/debug/InjectDebugData';
import { MarketplaceThemeProvider } from '../providers/MarketplaceThemeProvider';
import { MarketplaceEvents } from '../../../../../typings/marketplace';
+import { AppTitle } from '../../../ui/components/AppTitle';
+import { useApp } from '../../../os/apps/hooks/useApps';
export const MarketplaceApp = () => {
+ const marketplaceApp = useApp('SELLOUT');
+
return (
-
+
diff --git a/phone/src/apps/marketplace/components/MarketplaceTitle.tsx b/phone/src/apps/marketplace/components/MarketplaceTitle.tsx
deleted file mode 100644
index 9640a9b..0000000
--- a/phone/src/apps/marketplace/components/MarketplaceTitle.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import React from 'react';
-import Paper from '@material-ui/core/Paper';
-import { makeStyles } from '@material-ui/core';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faAd } from '@fortawesome/free-solid-svg-icons';
-
-const useStyles = makeStyles((theme) => ({
- root: {
- height: '60px',
- width: '100%',
- display: 'flex',
- flexFlow: 'row nowrap',
- justifyContent: 'center',
- alignItems: 'center',
- background: theme.palette.background.default,
- },
- icon: {
- color: theme.palette.primary.main,
- fontSize: 40,
- },
-}));
-
-export const MarketplaceTitle = () => {
- const classes = useStyles();
- return (
-
-
-
- );
-};
diff --git a/phone/src/apps/marketplace/components/form/ListingForm.tsx b/phone/src/apps/marketplace/components/form/ListingForm.tsx
index b11f835..46aa1b2 100644
--- a/phone/src/apps/marketplace/components/form/ListingForm.tsx
+++ b/phone/src/apps/marketplace/components/form/ListingForm.tsx
@@ -1,10 +1,14 @@
-import React, { useState } from 'react';
-import { makeStyles, Button, TextField } from '@material-ui/core';
+import React, { useEffect, useState, useCallback } from 'react';
+import { makeStyles, Button, TextField, Box } from '@material-ui/core';
import { useNuiRequest } from 'fivem-nui-react-lib';
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
-import { useHistory } from 'react-router';
+import ImageIcon from '@material-ui/icons/Image';
+import { useHistory, useLocation } from 'react-router-dom';
+import qs from 'qs';
+import { useQueryParams } from '../../../../common/hooks/useQueryParams';
+import { deleteQueryFromLocation } from '../../../../common/utils/deleteQueryFromLocation';
const useStyles = makeStyles((theme) => ({
root: {
@@ -36,6 +40,8 @@ export const ListingForm = () => {
const { t } = useTranslation();
const { addAlert } = useSnackbar();
const history = useHistory();
+ const { pathname, search } = useLocation();
+ const query = useQueryParams();
const [title, setTitle] = useState('');
const [url, setUrl] = useState('');
@@ -57,6 +63,26 @@ export const ListingForm = () => {
}
};
+ /*const handleChooseImage = () => {
+ history.push(`/camera?${qs.stringify({
+ referal: encodeURIComponent(pathname + search),
+ })}`)
+ }*/
+
+ const handleChooseImage = useCallback(() => {
+ history.push(
+ `/camera?${qs.stringify({
+ referal: encodeURIComponent(pathname + search),
+ })}`,
+ );
+ }, [history, pathname, search]);
+
+ useEffect(() => {
+ if (!query?.image) return;
+ setUrl(query?.image);
+ history.replace(deleteQueryFromLocation({ pathname, search }, 'image'));
+ }, [query?.image, history, pathname, search]);
+
return (
New Listing
@@ -76,10 +102,19 @@ export const ListingForm = () => {
}}
/>
+
+
+
+
+
+
+
+
setUrl(e.target.value)}
+ value={url}
+ onChange={(e) => setUrl(e.currentTarget.value)}
inputProps={{ className: classes.textFieldInput }}
style={{ width: '80%' }}
size="medium"
diff --git a/phone/src/apps/marketplace/components/navigation/NavigationBar.tsx b/phone/src/apps/marketplace/components/navigation/NavigationBar.tsx
index 686b886..37280bf 100644
--- a/phone/src/apps/marketplace/components/navigation/NavigationBar.tsx
+++ b/phone/src/apps/marketplace/components/navigation/NavigationBar.tsx
@@ -2,9 +2,7 @@ import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Link } from 'react-router-dom';
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faHome } from '@fortawesome/free-solid-svg-icons';
-import AddCircleIcon from '@material-ui/icons/AddCircle';
+import { AddCircle, Home } from '@material-ui/icons/';
const useStyles = makeStyles((theme) => ({
root: {
@@ -28,12 +26,8 @@ export const NavigationBar = () => {
showLabels
className={classes.root}
>
- }
- to="/marketplace"
- />
- } to="/marketplace/new" />
+ } to="/marketplace" />
+ } to="/marketplace/new" />
);
};
diff --git a/phone/src/apps/notes/NotesApp.tsx b/phone/src/apps/notes/NotesApp.tsx
index 5f66819..85d7c50 100644
--- a/phone/src/apps/notes/NotesApp.tsx
+++ b/phone/src/apps/notes/NotesApp.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { AppWrapper } from '../../ui/components/AppWrapper';
+import { AppWrapper } from '../../ui/components';
import { AppContent } from '../../ui/components/AppContent';
import { AppTitle } from '../../ui/components/AppTitle';
import { useApp } from '../../os/apps/hooks/useApps';
@@ -11,25 +11,23 @@ import { useNoteDetail } from './hooks/useNoteDetail';
import useStyles from './notes.styles';
import InjectDebugData from '../../os/debug/InjectDebugData';
import { NotesThemeProvider } from './providers/NotesThemeProvider';
-import { Route, useHistory } from 'react-router-dom';
+import { Route } from 'react-router-dom';
import { NotesEvents } from '../../../../typings/notes';
export const NotesApp = () => {
const classes = useStyles();
- const history = useHistory();
const notesApp = useApp('NOTES');
const { setDetail } = useNoteDetail();
const onClickCreate = () => {
setDetail({ title: '', content: '' });
- history.push('/notes/detail');
};
return (
-
+
diff --git a/phone/src/apps/notes/NotesTitle.tsx b/phone/src/apps/notes/NotesTitle.tsx
deleted file mode 100644
index 9f020a6..0000000
--- a/phone/src/apps/notes/NotesTitle.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import React from 'react';
-
-import { makeStyles, Paper } from '@material-ui/core';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
-
-const useStyles = makeStyles((theme) => ({
- header: {
- width: '100%',
- display: 'flex',
- flexFlow: 'row nowrap',
- justifyContent: 'center',
- alignItems: 'center',
- textAlign: 'center',
- height: '60px',
- },
- icon: {
- color: theme.palette.primary.main,
- fontSize: 40,
- },
-}));
-
-const NotesTitle = () => {
- const classes = useStyles();
- return (
-
-
-
- );
-};
-
-export default NotesTitle;
diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx
index 088cc40..cfe8259 100644
--- a/phone/src/apps/notes/list/NoteList.tsx
+++ b/phone/src/apps/notes/list/NoteList.tsx
@@ -2,18 +2,14 @@ import React from 'react';
import { List, ListItem, ListItemText } from '@material-ui/core';
import { useNoteDetail } from '../hooks/useNoteDetail';
import { useNotes } from '../hooks/useNotes';
-import { useHistory } from 'react-router-dom';
-// add search bar later
-// TODO: Add interface for note
+// TODO: add search bar later
const NoteList = () => {
- const history = useHistory();
const { notes } = useNotes();
const { setDetail } = useNoteDetail();
const handleNoteModal = (note) => {
setDetail(note);
- history.push('/notes/detail');
};
return (
diff --git a/phone/src/apps/notes/modal/NoteModal.tsx b/phone/src/apps/notes/modal/NoteModal.tsx
index 227e595..35dbf52 100644
--- a/phone/src/apps/notes/modal/NoteModal.tsx
+++ b/phone/src/apps/notes/modal/NoteModal.tsx
@@ -14,48 +14,38 @@ import { useNoteDetail } from '../hooks/useNoteDetail';
import useStyles from './modal.styles';
import { useNuiRequest } from 'fivem-nui-react-lib';
import { useTranslation } from 'react-i18next';
-import { useHistory } from 'react-router-dom';
import { StatusButton } from '../../../ui/components/StatusButton';
import { NotesEvents } from '../../../../../typings/notes';
export const NoteModal = () => {
const Nui = useNuiRequest();
const classes = useStyles();
- const history = useHistory();
const { t } = useTranslation();
const { detail, setDetail } = useNoteDetail();
- const onClose = () => history.goBack();
-
const _handleClose = () => {
setDetail(null);
- onClose();
};
const handleNoteSave = () => {
Nui.send(NotesEvents.ADD_NOTE, detail);
setDetail(null);
- onClose();
};
const handleDeleteNote = () => {
const id = detail.id;
- Nui.send(NotesEvents.DELETE_NOTE, {
- id,
- });
+ Nui.send(NotesEvents.DELETE_NOTE, id);
setDetail(null);
- onClose();
};
const handleUpdateNote = () => {
Nui.send(NotesEvents.UPDATE_NOTE, detail);
setDetail(null);
- onClose();
};
return (
-
-
+
+
{!detail ? (
) : (
diff --git a/phone/src/apps/twitter/components/buttons/RetweetButton.tsx b/phone/src/apps/twitter/components/buttons/RetweetButton.tsx
index 4fe98d1..3b331b4 100644
--- a/phone/src/apps/twitter/components/buttons/RetweetButton.tsx
+++ b/phone/src/apps/twitter/components/buttons/RetweetButton.tsx
@@ -1,8 +1,7 @@
import React, { useState } from 'react';
import { CircularProgress, makeStyles, Button } from '@material-ui/core';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faRetweet } from '@fortawesome/free-solid-svg-icons';
import { useNuiRequest } from 'fivem-nui-react-lib';
+import { Repeat } from '@material-ui/icons';
import { TwitterEvents } from '../../../../../../typings/twitter';
interface IProps {
@@ -55,7 +54,7 @@ export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
return (
);
};
diff --git a/phone/src/apps/twitter/components/tweet/Retweet.tsx b/phone/src/apps/twitter/components/tweet/Retweet.tsx
index 18f7e0d..add068c 100644
--- a/phone/src/apps/twitter/components/tweet/Retweet.tsx
+++ b/phone/src/apps/twitter/components/tweet/Retweet.tsx
@@ -1,8 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faRetweet } from '@fortawesome/free-solid-svg-icons';
+import { Repeat } from '@material-ui/icons';
interface IProps {
profileName: string;
@@ -25,7 +24,7 @@ function Retweet({ profileName }: IProps) {
const classes = useStyles();
return (
- {profileName} {t('APPS_TWITTER_RETWEETED')}
+ {profileName} {t('APPS_TWITTER_RETWEETED')}
);
}
diff --git a/phone/src/config/default.json b/phone/src/config/default.json
index d912043..988c763 100644
--- a/phone/src/config/default.json
+++ b/phone/src/config/default.json
@@ -107,6 +107,10 @@
{
"label": "Bosanski",
"value": "ba"
+ },
+ {
+ "label": "Hungarian",
+ "value": "hu"
}
],
"ringtones": [
diff --git a/phone/src/i18n.ts b/phone/src/i18n.ts
index 22e3ca1..b103aa6 100644
--- a/phone/src/i18n.ts
+++ b/phone/src/i18n.ts
@@ -8,6 +8,7 @@ import sv from './locale/sv.json';
import no from './locale/no.json';
import tr from './locale/tr.json';
import ptbr from './locale/ptbr.json';
+import hu from "./locale/hu.json"
import pt from './locale/pt.json';
import config from './config/default.json';
@@ -21,6 +22,7 @@ const resources = {
tr,
ptbr,
pt,
+ hu
};
i18n
diff --git a/phone/src/index.tsx b/phone/src/index.tsx
index 8899b52..4594604 100644
--- a/phone/src/index.tsx
+++ b/phone/src/index.tsx
@@ -7,7 +7,7 @@ import * as Sentry from '@sentry/react';
import { Integrations } from '@sentry/tracing';
import './main.css';
import PhoneConfig from './config/default.json';
-import { PhoneContainer } from './PhoneContainer';
+import { PhoneProviders } from './PhoneProviders';
import attachMockNuiEvent from './os/debug/AttachMockNuiEvent';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
@@ -34,7 +34,7 @@ if (process.env.NODE_ENV === 'development') attachMockNuiEvent();
ReactDOM.render(
-
+
,
document.getElementById('root'),
diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json
index b3a9418..01ca1e5 100644
--- a/phone/src/locale/en.json
+++ b/phone/src/locale/en.json
@@ -59,7 +59,7 @@
"APPS_NOTES": "Notes",
"APPS_EXAMPLE": "Example app",
"APPS_TWITTER": "Twitter",
- "APPS_SELLOUT": "Market",
+ "APPS_SELLOUT": "Marketplace",
"APPS_CAMERA": "Camera",
"APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "Photo could not be saved :(",
diff --git a/phone/src/locale/es.json b/phone/src/locale/es.json
index 1043cd0..e584923 100644
--- a/phone/src/locale/es.json
+++ b/phone/src/locale/es.json
@@ -2,6 +2,50 @@
"translation": {
"DATE_FORMAT": "MM/DD/YYYY",
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
+ "CALLS": {
+ "MESSAGES": {
+ "RINGING": "Llamando",
+ "OUTGOING": "Llamada saliente",
+ "INCOMING": "Llamada entrante"
+ }
+ },
+ "SETTINGS": {
+ "CATEGORY": {
+ "APPEARANCE": "Apariencia",
+ "PHONE": "Celular",
+ "ACTIONS": "Acciones"
+ },
+ "OPTIONS": {
+ "LANGUAGE": "Lenguaje",
+ "RESET_SETTINGS": "Restablecer configuraciones",
+ "RESET_SETTINGS_DESC": "Esto borrara tus datos almacenados localmente",
+ "CUSTOM_WALLPAPER": {
+ "DIALOG_TITLE": "Wallpaper personalizado",
+ "DIALOG_CONTENT": "Define un wallpaper personalizado ingresando la URL de la imagen abajo!",
+ "DIALOG_PLACEHOLDER": "URL imagen",
+ "DIALOG_ERROR": "Imagen o link invalido"
+ }
+ },
+ "MESSAGES": {
+ "INVALID_SETTINGS": "Configuracion invalida! Restablece la configuracion del dispositivo.",
+ "SETTINGS_RESET": "Se restablecieron las configuraciones!"
+ }
+ },
+ "RELATIVE_TIME": {
+ "future": "en %s",
+ "past": "hace %s",
+ "s": "hace unos segundos",
+ "m": "hace un minuto",
+ "mm": "%d minutos",
+ "h": "hace una hora",
+ "hh": "%d horas",
+ "d": "hace un dia",
+ "dd": "%d dias",
+ "M": "hace un mes",
+ "MM": "%d meses",
+ "y": "hace un año",
+ "yy": "%d años"
+ },
"COMING_SOON": "Próximamente...",
diff --git a/phone/src/locale/hu.json b/phone/src/locale/hu.json
new file mode 100644
index 0000000..7a8b26d
--- /dev/null
+++ b/phone/src/locale/hu.json
@@ -0,0 +1,242 @@
+{
+ "translation": {
+ "DATE_FORMAT": "MM/DD/YYYY",
+ "DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
+ "CALLS": {
+ "MESSAGES": {
+ "RINGING": "Csengetés...",
+ "OUTGOING": "Kimenő hívás",
+ "INCOMING": "Bejövő hívás"
+ }
+ },
+ "SETTINGS": {
+ "CATEGORY": {
+ "APPEARANCE": "Megjelenés",
+ "PHONE": "Telefon",
+ "ACTIONS": "Műveletek"
+ },
+ "OPTIONS": {
+ "LANGUAGE": "Nyelv",
+ "RESET_SETTINGS": "Beállítások visszaállítása",
+ "RESET_SETTINGS_DESC": "Ez törli a helyileg mentett adataid",
+ "CUSTOM_WALLPAPER": {
+ "DIALOG_TITLE": "Saját háttér",
+ "DIALOG_CONTENT": "Állíts be saját hátteret a kép URL-jének megadásával",
+ "DIALOG_PLACEHOLDER": "Kép URL",
+ "DIALOG_ERROR": "Hibás kép/fájltípus"
+ }
+ },
+ "MESSAGES": {
+ "INVALID_SETTINGS": "Hibás beállítások, állítsd vissza őket a Beállításokban!",
+ "SETTINGS_RESET": "Beállítások visszaállítva!"
+ }
+ },
+ "RELATIVE_TIME": {
+ "future": "%s múlva",
+ "past": "%s ago",
+ "s": "pár másodperce",
+ "m": "egy perce",
+ "mm": "%d perce",
+ "h": "egy órája",
+ "hh": "%d órája",
+ "d": "egy napja",
+ "dd": "%d napja",
+ "M": "egy hónapja",
+ "MM": "%d hónapja",
+ "y": "egy éve",
+ "yy": "%d éve"
+ },
+
+ "COMING_SOON": "Hamarosan...",
+ "INITIALIZING": "Betöltés",
+
+ "APPS_DIALER": "Telefon",
+ "APPS_CONTACTS": "Névlista",
+ "APPS_MESSAGES": "Üzenetek",
+ "APPS_CALCULATOR": "Számológép",
+ "APPS_SETTINGS": "Beállítások",
+ "APPS_BANK": "WhoDis bank",
+ "APPS_NOTES": "Jegyzetek",
+ "APPS_EXAMPLE": "Péla app",
+ "APPS_TWITTER": "Twitter",
+ "APPS_SELLOUT": "Pia",
+ "APPS_CAMERA": "Kamera",
+
+ "APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "Nem lehet elmenteni a képet :(",
+
+ "APPS_DIALER_INCOMING_CALL_TITLE": "Bejövő hívás",
+ "APPS_DIALER_CURRENT_CALL_TITLE": "Jelenlegi hívás",
+ "APPS_DIALER_CURRENT_CALL_WITH": "Hivásban: {{ transmitter }}",
+ "APPS_DIALER_TRANSMITTER_IS_CALLING": "{{ transmitter }} hív téged!",
+ "APPS_DIALER_ACCEPT_CALL": "Elfogad",
+ "APPS_DIALER_REJECT_CALL": "Elutasít",
+ "APPS_DIALER_END_CALL": "Befejezés",
+ "APPS_DIALER_INPUT_PLACEHOLDER": "Írj be egy számot",
+ "APPS_DIALER_NO_HISTORY": "Nincsenek előző hívások",
+ "APPS_DIALER_NAVBAR_HISTORY": "Előző hívások",
+ "APPS_DIALER_NAVBAR_DIAL": "Tárcsáz",
+ "APPS_DIALER_NAVBAR_CONTACTS": "Kontaktok",
+
+ "APPS_TWITTER_TWEET": "Tweet",
+ "APPS_TWITTER_TWEET_MESSAGE_PLACEHOLDER": "Mi történik?",
+ "APPS_TWITTER_IMAGE_PLACEHOLDER": "Egy link a képhez vagy gifhez",
+ "APPS_TWITTER_SUBMIT_IMAGE": "Média hozzáadása",
+ "APPS_TWITTER_CLOSE_IMAGE": "Bezár",
+ "APPS_TWITTER_CLOSE": "Bezár",
+ "APPS_TWITTER_DELETE": "Törlés",
+ "APPS_TWITTER_REPORT": "Jelentés",
+ "APPS_TWITTER_REPORTED": " Jelentve",
+ "APPS_TWITTER_RETWEETED": "Retweetelve",
+ "APPS_TWITTER_JUST_NOW": "Éppen most",
+ "APPS_TWITTER_SEARCH_TWEETS": "Tweetek keresése",
+ "APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER": "Keresés üzenet vagy profil alapján",
+ "APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT": "Az üzenet meghaladja a maximális hosszúságot",
+ "APPS_TWITTER_TWEET_MESSAGE_NEW_LINE_LIMIT": "Az üzenet meghaladja a maximális új-sorok számát",
+ "APPS_TWITTER_CREATE_SUCCESS": "Sikeres tweet!",
+ "APPS_TWITTER_CREATE_FAILED": "Hiba a tweet megosztásában",
+ "APPS_TWITTER_EDIT_PROFILE_AVATAR": "Profilkép URL",
+ "APPS_TWITTER_EDIT_PROFILE_NAME": "Profil név",
+ "APPS_TWITTER_EDIT_DEFAULT_PROFILE_NAME": "Válaszd ki a profilneved",
+ "APPS_TWITTER_EDIT_PROFILE_BIO": "Rólam",
+ "APPS_TWITTER_EDIT_PROFILE_LOCATION": "Hely",
+ "APPS_TWITTER_EDIT_PROFILE_JOB": "Munka",
+ "APPS_TWITTER_CREATE_PROFILE_SUCCESS": "Profil sikeresen létrehozva",
+ "APPS_TWITTER_CREATE_PROFILE_FAILURE": "Hiba a profil létrehozása közben",
+ "APPS_TWITTER_EDIT_PROFILE_SUCCESS": "Profil sikeresen frissítve",
+ "APPS_TWITTER_EDIT_PROFILE_FAILURE": "Nem sikerült a profil frissítése",
+ "APPS_TWITTER_RETWEET_EXISTS": "Ezt a tweetet már retweetelted!",
+ "APPS_TWITTER_TIME_JUST_NOW": "Éppen most",
+ "APPS_TWITTER_TIME_MINUTES": "p",
+ "APPS_TWITTER_TIME_HOURS": "ó",
+ "APPS_TWITTER_TIME_DAYS": "n",
+ "APPS_TWITTER_NEW_BROADCAST": "Új tweet, tőle: @{{ profile_name }}!",
+ "APPS_TWITTER_NEW_RETWEET_BROADCAST": "@{{ profile_name }} retweetelt valamit!",
+ "APPS_TWITTER_UNREAD_MESSAGES": "Van {{ count }} új tweet a profilodon!",
+
+ "APPS_MATCH": "Párkereső",
+ "APPS_MATCH_LIKED": "Tetszik",
+ "APPS_MATCH_NOPE": "Eh..",
+ "APPS_MATCH_LIKE": "Tetszik",
+ "APPS_MATCH_DISLIKE": "Nem tetszik",
+ "APPS_MATCH_NO_PROFILES": "Nincs profil a közeledben",
+ "APPS_MATCH_NO_MATCHES": "Nincsenek veled párba állt emberek",
+ "APPS_MATCH_PROFILES_ERROR": "Hiba a profilok betöltése közben",
+ "APPS_MATCH_MATCHES_ERROR": "Hiba a párok betöltése közben",
+ "APPS_MATCH_PROFILE_CONFIGURATION": "Hibásan van beállítva az app, kérlek szólj egy adminnak.",
+ "APPS_MATCH_MY_PROFILE_ERROR": "Hiba a profil betöltése közben",
+ "APPS_MATCH_PROFILE_LAST_ACTIVE": "Utoljára elérhető: {{ lastActive }}",
+ "APPS_MATCH_PROFILE_MATCHED_AT": "Párba állt: {{ matchedAt }}",
+ "APPS_MATCH_EDIT_PROFILE_PREVIEW": "Bemutató megnézése",
+ "APPS_MATCH_EDIT_PROFILE_IMAGE": "Kép URL",
+ "APPS_MATCH_EDIT_PROFILE_NAME": "Profil név",
+ "APPS_MATCH_EDIT_PROFILE_BIO": "Bio",
+ "APPS_MATCH_EDIT_PROFILE_LOCATION": "Hely",
+ "APPS_MATCH_EDIT_PROFILE_JOB": "Munka",
+ "APPS_MATCH_EDIT_PROFILE_TAGS": "Tagek",
+ "APPS_MATCH_GET_MY_PROFILE_FAILED": "Nem lehet lekéni a játékos profilját",
+ "APPS_MATCH_GET_PROFILES_FAILED": "Nem lehet lekéni a profilokat",
+ "APPS_MATCH_GET_MATCHES_FAILED": "Nem lehet lekéni a párokat",
+ "APPS_MATCH_UPDATE_PROFILE_SUCCEEDED": "Profil sikeresen frissítve",
+ "APPS_MATCH_UPDATE_PROFILE_FAILED": "Nem sikerült a profil frissítése",
+ "APPS_MATCH_CREATE_PROFILE_FAILED": "Hiba a profil létrehozása közben",
+ "APPS_MATCH_SAVE_LIKES_FAILED": "Hiba a likeok mentése közben",
+ "APPS_MATCH_SAVE_LIKES_SUCCEDED": "Likeok mentve",
+ "APPS_MATCH_NEW_LIKE_FOUND": "Nem található pár!",
+
+ "APPS_BANK_TRANSFER": "Utalás",
+ "APPS_BANK_HOME_TITLE": "Üdvözölljük",
+ "APPS_BANK_ACCOUNT_LINK": "Fiók",
+ "APPS_BANK_TIME_JUST_NOW": "Éppen most",
+ "APPS_BANK_ACCOUNT_TITLE": "Fiókom",
+ "APPS_BANK_ACCOUNT_TRANSACTIONS": "Tranzakciók",
+ "APPS_BANK_ACCOUNT_SEE_TRANSACTION": "Mutasd mind",
+ "APPS_BANK_ACTIONS_TRANSFER": "Átutalás",
+ "APPS_BANK_ALERT_TRANSFER_SUCCESS": "Sikeres átutalás",
+ "APPS_BANK_ALERT_TRANSFER_FAILURE": "Sikertelen átutalás",
+
+ "APPS_MESSAGES_SEARCH_PLACEHOLDER": "Üzenetek keresése...",
+ "APPS_MESSAGES_NEW_MESSAGE": "Üzenet...",
+ "APPS_MESSAGES_NEW_MESSAGE_FAILED:": "Nem lehet elküldeni az üzenetet",
+ "APPS_MESSAGES_NEW_MESSAGE_GROUP": "Telefonszámok...",
+ "APPS_MESSAGES_GROUP_CHAT_LABEL": "Csoportos beszélgetés címe...",
+ "APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT": "Küldés",
+ "APPS_MESSAGES_INVALID_PHONE_NUMBER": "Hibás telefonszám",
+ "APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "Ez az csoport már létezik",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Hiba a csoport létrehozása közben",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "Nem tudod hozzáadni saját magad!",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_ALL_NUMBERS_FAILED": "Egyik szám sem létezik!",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_ONE_NUMBER_FAILED": "A {{ number }} nem egy regisztrált szám",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_SOME_NUMBERS_FAILED": "({{ numbers }}) nem regisztrált számok.",
+ "APPS_MESSAGES_INPUT_NAME_OR_NUMBER": "Kontakot keresése, vagy írj be egy telefonszámot",
+ "APPS_MESSAGES_UNREAD_MESSAGES": "{{ count }} olvasatlan üzeneted van",
+ "APPS_MESSAGES_MEMBERS_TITLE": "Tagok",
+ "APPS_MESSAGES_ME": "Én",
+
+ "APPS_CONTACT_FORM_NAME": "Név",
+ "APPS_CONTACT_FORM_NUMBER": "Szám",
+ "APPS_CONTACT_FORM_AVATAR": "Avatar URL",
+
+ "APPS_CONTACT_ADD_SUCCESS": "Kontakt sikeresen létrehozva",
+ "APPS_CONTACT_ADD_FAILED": "Hiba a kontakt létrehozása közben",
+ "APPS_CONTACT_UPDATE_SUCCESS": "Kontakt frissítve!",
+ "APPS_CONTACT_UPDATE_FAILED": "A kontakt frissítése sikertelen!",
+ "APPS_CONTACT_DELETE_SUCCESS": "Kontakt törölve!",
+ "APPS_CONTACT_DELETE_FAILED": "Nem sikerült a kontakt törlése!",
+ "APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS": "Kontaktok keresése",
+ "APPS_CONTACT_MODAL_PLACEHOLDER_NAME": "Név",
+ "APPS_CONTACT_MODAL_PLACEHOLDER_NUMBER": "Szám",
+ "APPS_CONTACT_MODAL_PLACEHOLDER_AVATAR": "Avatar",
+ "APPS_CONTACT_MODAL_BUTTON_ADD": "Kontakt hozzáadása",
+
+ "APPS_NOTES_ADD_SUCCESS": "Jegyzet mentve",
+ "APPS_NOTES_ADD_FAILED": "Hiba a jegyzet mentése közben.",
+ "APPS_NOTES_UPDATE_SUCCESS": "Jegyzet frissítve.",
+ "APPS_NOTES_UPDATE_FAILED": "Hiba a jegyzet frissítése közben.",
+ "APPS_NOTES_DELETE_SUCCESS": "Jegyzet törölve.",
+ "APPS_NOTES_DELETE_FAILED": "Hiba a jegyzet törlése közben.",
+
+ "APPS_CALCULATOR_COPIED": "Másolva a vágólapra!",
+
+ "APPS_SETTINGS_PHONE_NUMBER": "Telefonszám",
+ "APPS_SETTINGS_OPTION_WALLPAPER": "Háttér",
+ "APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER": "Saját háttér",
+ "APPS_SETTINGS_OPTION_FRAME": "Keret",
+ "APPS_SETTINGS_OPTION_THEME": "Téma",
+ "APPS_SETTINGS_OPTION_ZOOM": "Nagyítás",
+ "APPS_SETTINGS_OPTION_STREAMER_MODE": "Streamer mód",
+ "APPS_SETTINGS_OPTION_RINGTONE": "Csengőhang",
+ "APPS_SETTINGS_OPTION_RINGTONEVOL": "Csengőhang hangereje",
+ "APPS_SETTINGS_OPTION_NOTIFICATION_FILTER": "Értesítés filter",
+ "APPS_SETTINGS_OPTION_NOTIFICATION": "Értesítés",
+ "APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Értesítés hangereje",
+ "APPS_SETTING_STREAMER_MODE_DESC": "Képek elrejtése",
+
+ "APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Új termék közzétéve",
+ "APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Hiba az új termék közzététele közben",
+ "APPS_MARKETPLACE_DELETE_LISTING_SUCCESS": "Termék törölve",
+ "APPS_MARKETPLACE_DELETE_LISTING_FAILED": "Hiba a termék törlése közben",
+ "APPS_MARKETPLACE_REPORT_LISTING_FAILED": "Ezt a terméket már jelentetted",
+ "APPS_MARKETPLACE_REPORT_LISTING_SUCCESS": "Termék jelentve",
+ "APPS_MARKETPLACE_REQUIRED_FIELDS": "Minden kötelező mezőt ki kell tölteni!",
+ "APPS_MARKETPLACE_FORM_TITLE": "Cím",
+ "APPS_MARKETPLACE_FORM_IMAGE": "Kép vagy URL",
+ "APPS_MARKETPLACE_FORM_DESCRIPTION": "Leírás",
+
+ "GENERIC_CLICK_TO_REVEAL": "Kattints a megtekintéshez",
+ "GENERIC_LOADING": "Töltés...",
+ "GENERIC_WAIT": "Kérlek várj...",
+ "GENERIC_SAVE": "Mentés",
+ "GENERIC_UPDATE": "Frissítés",
+ "GENERIC_REQUIRED": "Kötelező",
+ "GENERIC_DELETE": "Törlés",
+ "GENERIC_REPORT": "Jelentés",
+ "GENERIC_CALL": "Hívás",
+ "GENERIC_MESSAGE": "Üzenet",
+ "GENERIC_CLOSE": "Bezár",
+ "GENERIC_CANCEL": "Mégse",
+ "GENERIC_TITLE": "Cím",
+ "GENERIC_CONTENT": "Tartalom",
+ "GENERIC_WRITE_TO_CLIPBOARD_TOOLTIP": "Másolás: {{ content }}",
+ "GENERIC_WRITE_TO_CLIPBOARD_MESSAGE": "{{content}} másolva a vágólapra!"
+ }
+}
diff --git a/phone/src/locale/ptbr.json b/phone/src/locale/ptbr.json
index bb057e0..fb5cd2a 100644
--- a/phone/src/locale/ptbr.json
+++ b/phone/src/locale/ptbr.json
@@ -2,6 +2,13 @@
"translation": {
"DATE_FORMAT": "DD/MM/YYYY",
"DATE_TIME_FORMAT": "DD/MM/YYYY hh:mm A",
+ "CALLS": {
+ "MESSAGES": {
+ "RINGING": "Tocando",
+ "OUTGOING": "Enviando chamada",
+ "INCOMING": "Chamada recebida"
+ }
+ },
"SETTINGS": {
"CATEGORY": {
"APPEARANCE": "Aparência",
@@ -11,7 +18,13 @@
"OPTIONS": {
"LANGUAGE": "Idioma",
"RESET_SETTINGS": "Redefinir as configurações",
- "RESET_SETTINGS_DESC": "Isso limpará seus dados armazenados localmente"
+ "RESET_SETTINGS_DESC": "Isso limpará seus dados armazenados localmente",
+ "CUSTOM_WALLPAPER": {
+ "DIALOG_TITLE": "Plano de Fundo customizado",
+ "DIALOG_CONTENT": "Defina um Plano de Fundo customizado inserindo a URL da imagem abaixo!",
+ "DIALOG_PLACEHOLDER": "URL da Imagem",
+ "DIALOG_ERROR": "Imagem ou link inválido"
+ }
},
"MESSAGES": {
"INVALID_SETTINGS": "Configurações armazenadas inválidas! Redefina no aplicativo Configurações.",
@@ -49,10 +62,12 @@
"APPS_SELLOUT": "Mercado",
"APPS_CAMERA": "Camera",
+ "APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "Não foi possível salvar a foto :(",
+
"APPS_DIALER_INCOMING_CALL_TITLE": "Ligação",
"APPS_DIALER_CURRENT_CALL_TITLE": "Chamada atual",
"APPS_DIALER_CURRENT_CALL_WITH": "Em ligação com {{ transmitter }}",
- "APPS_DIALER_TRANSMITTER_IS_CALLING": "{{ transmitter }} Esta te ligando!",
+ "APPS_DIALER_TRANSMITTER_IS_CALLING": "{{ transmitter }} esta te ligando!",
"APPS_DIALER_ACCEPT_CALL": "Atender",
"APPS_DIALER_REJECT_CALL": "Rejeitar",
"APPS_DIALER_END_CALL": "Fim",
@@ -180,7 +195,7 @@
"APPS_NOTES_DELETE_SUCCESS": "Nota deletada com sucesso.",
"APPS_NOTES_DELETE_FAILED": "Falha em deletar nota.",
- "APPS_CALCULATOR_COPIED": "Resultado foi copiado para a área de transferência!",
+ "APPS_CALCULATOR_COPIED": "Resultado copiado para a área de transferência!",
"APPS_SETTINGS_PHONE_NUMBER": "Número de telefone",
"APPS_SETTINGS_OPTION_WALLPAPER": "Papel de parede",
@@ -195,7 +210,6 @@
"APPS_SETTINGS_OPTION_NOTIFICATION": "Notificação",
"APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Volume das notificações",
"APPS_SETTING_STREAMER_MODE_DESC": "Ocultar as imagens antes de serem mostradas",
- "APPS_SETTINGS_SET_CUSTOM_WALLPAPER": "Definir novo papel de parede",
"APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Lista sendo criada com sucesso",
"APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Falha em criar nova lista",
@@ -209,6 +223,7 @@
"APPS_MARKETPLACE_FORM_DESCRIPTION": "Descrição",
"GENERIC_CLICK_TO_REVEAL": "Clique para revelar",
+ "GENERIC_LOADING": "Carregando",
"GENERIC_WAIT": "Por favor, espere...",
"GENERIC_SAVE": "Salvar",
"GENERIC_UPDATE": "Atualizar",
diff --git a/phone/yarn.lock b/phone/yarn.lock
index e64237d..c6f7cfd 100644
--- a/phone/yarn.lock
+++ b/phone/yarn.lock
@@ -1233,44 +1233,6 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"
-"@fortawesome/fontawesome-common-types@^0.2.32":
- version "0.2.32"
- resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.32.tgz#3436795d5684f22742989bfa08f46f50f516f259"
- integrity sha512-ux2EDjKMpcdHBVLi/eWZynnPxs0BtFVXJkgHIxXRl+9ZFaHPvYamAfCzeeQFqHRjuJtX90wVnMRaMQAAlctz3w==
-
-"@fortawesome/fontawesome-common-types@^0.2.35":
- version "0.2.35"
- resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz#01dd3d054da07a00b764d78748df20daf2b317e9"
- integrity sha512-IHUfxSEDS9dDGqYwIW7wTN6tn/O8E0n5PcAHz9cAaBoZw6UpG20IG/YM3NNLaGPwPqgjBAFjIURzqoQs3rrtuw==
-
-"@fortawesome/fontawesome-svg-core@^1.2.35":
- version "1.2.35"
- resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.35.tgz#85aea8c25645fcec88d35f2eb1045c38d3e65cff"
- integrity sha512-uLEXifXIL7hnh2sNZQrIJWNol7cTVIzwI+4qcBIq9QWaZqUblm0IDrtSqbNg+3SQf8SMGHkiSigD++rHmCHjBg==
- dependencies:
- "@fortawesome/fontawesome-common-types" "^0.2.35"
-
-"@fortawesome/free-brands-svg-icons@^5.15.1":
- version "5.15.1"
- resolved "https://registry.yarnpkg.com/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-5.15.1.tgz#1dc0563f4036639e53d24b8e532ea78a53ca2250"
- integrity sha512-pkTZIWn7iuliCCgV+huDfZmZb2UjslalXGDA2PcqOVUYJmYL11y6ooFiMJkJvUZu+xgAc1gZgQe+Px12mZF0CA==
- dependencies:
- "@fortawesome/fontawesome-common-types" "^0.2.32"
-
-"@fortawesome/free-solid-svg-icons@^5.15.1":
- version "5.15.1"
- resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.1.tgz#e1432676ddd43108b41197fee9f86d910ad458ef"
- integrity sha512-EFMuKtzRMNbvjab/SvJBaOOpaqJfdSap/Nl6hst7CgrJxwfORR1drdTV6q1Ib/JVzq4xObdTDcT6sqTaXMqfdg==
- dependencies:
- "@fortawesome/fontawesome-common-types" "^0.2.32"
-
-"@fortawesome/react-fontawesome@^0.1.14":
- version "0.1.14"
- resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.14.tgz#bf28875c3935b69ce2dc620e1060b217a47f64ca"
- integrity sha512-4wqNb0gRLVaBm/h+lGe8UfPPivcbuJ6ecI4hIgW0LjI7kzpYB9FkN0L9apbVzg+lsBdcTf0AlBtODjcSX5mmKA==
- dependencies:
- prop-types "^15.7.2"
-
"@hapi/address@2.x.x":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
@@ -5422,12 +5384,10 @@ find-up@^3.0.0:
dependencies:
locate-path "^3.0.0"
-fivem-nui-react-lib@2.2.6:
- version "2.2.6"
- resolved "https://registry.yarnpkg.com/fivem-nui-react-lib/-/fivem-nui-react-lib-2.2.6.tgz#2ffc01aee5a01aeb444c7c404e3e2b374b9798d7"
- integrity sha512-h8WJsyP7/VehkmRdfs9/pjGK73LmZSEeWH4kW0Mo9InC0qIulcTfJnnvdp40fIJ6SSCZLjteSQrUN6f+ZUoKdA==
- dependencies:
- typescript "^4.1.2"
+fivem-nui-react-lib@^2.2.8:
+ version "2.2.8"
+ resolved "https://registry.yarnpkg.com/fivem-nui-react-lib/-/fivem-nui-react-lib-2.2.8.tgz#41df54b37cbb61806f44a5d426e4c5ec6387fde9"
+ integrity sha512-8eeCp3J1yS4ymFpRwig72dcIJviF+63ug1j4GBZXBzo1QmKyDjRCR36HwBhl2YKYgYyC4sJbTSeT+k6T61F3Fg==
flat-cache@^3.0.4:
version "3.0.4"
@@ -5943,9 +5903,9 @@ hoopy@^0.1.4:
integrity sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==
hosted-git-info@^2.1.4:
- version "2.8.8"
- resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
- integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
+ version "2.8.9"
+ resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
+ integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
howler@^2.2.1:
version "2.2.1"
@@ -10918,9 +10878,9 @@ sshpk@^1.7.0:
tweetnacl "~0.14.0"
ssri@^6.0.1:
- version "6.0.1"
- resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
- integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
+ integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==
dependencies:
figgy-pudding "^3.5.1"
@@ -11604,11 +11564,6 @@ typescript@3.9.7:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
-typescript@^4.1.2:
- version "4.2.3"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
- integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
-
unbox-primitive@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.0.tgz#eeacbc4affa28e9b3d36b5eaeccc50b3251b1d3f"
diff --git a/resources/client/cl_call.ts b/resources/client/cl_call.ts
index 65f0ec3..79e4a32 100644
--- a/resources/client/cl_call.ts
+++ b/resources/client/cl_call.ts
@@ -118,7 +118,7 @@ function openCallModal(show: boolean) {
);
}
-onNet(CallEvents.SEND_HISTORY, (calls: CallHistoryItem[]) => {
+onNet(CallEvents.FETCH_CALLS, (calls: CallHistoryItem[]) => {
SendNuiMessage(
JSON.stringify({
app: 'DIALER',
diff --git a/resources/client/cl_contacts.ts b/resources/client/cl_contacts.ts
index 796eb16..ddcb9f8 100644
--- a/resources/client/cl_contacts.ts
+++ b/resources/client/cl_contacts.ts
@@ -1,4 +1,4 @@
-import { ContactEvents } from '../../typings/contact';
+import { ContactEvents, PreDBContact } from '../../typings/contact';
import { sendContactsEvent } from '../utils/messages';
onNet(ContactEvents.SEND_CONTACTS, (contacts: any) => {
@@ -6,8 +6,8 @@ onNet(ContactEvents.SEND_CONTACTS, (contacts: any) => {
});
RegisterNuiCallbackType(ContactEvents.ADD_CONTACT);
-on(`__cfx_nui:${ContactEvents.ADD_CONTACT}`, (data: any, cb: Function) => {
- emitNet(ContactEvents.ADD_CONTACT, data.number, data.display, data.avatar);
+on(`__cfx_nui:${ContactEvents.ADD_CONTACT}`, (data: PreDBContact, cb: Function) => {
+ emitNet(ContactEvents.ADD_CONTACT, data);
cb();
});
diff --git a/resources/client/cl_controls.lua b/resources/client/cl_controls.lua
new file mode 100644
index 0000000..bf42d64
--- /dev/null
+++ b/resources/client/cl_controls.lua
@@ -0,0 +1,43 @@
+local disableKeys
+
+CreateThread(function()
+ while true do
+ if disableKeys then
+ Wait(0)
+ DisableControlAction(0, 0, true) -- Next Camera
+ DisableControlAction(0, 1, true) -- Look Left/Right
+ DisableControlAction(0, 2, true) -- Look up/Down
+ DisableControlAction(0, 16, true) -- Next Weapon
+ DisableControlAction(0, 17, true) -- Select Previous Weapon
+ DisableControlAction(0, 22, true) -- Jump
+ DisableControlAction(0, 24, true) -- Attack
+ DisableControlAction(0, 25, true) -- Aim
+ DisableControlAction(0, 26, true) -- Look Behind
+ DisableControlAction(0, 37, true) -- Weapon Wheel
+ DisableControlAction(0, 44, true) -- Cover
+ DisableControlAction(0, 47, true) -- Detonate
+ DisableControlAction(0, 55, true) -- Dive
+ DisableControlAction(0, 75, true) -- Exit Vehicle
+ DisableControlAction(0, 76, true) -- Vehicle Handbrake
+ DisableControlAction(0, 81, true) -- Next Radio (Vehicle)
+ DisableControlAction(0, 82, true) -- Previous Radio (Vehicle)
+ DisableControlAction(0, 91, true) -- Passenger Aim (Vehicle)
+ DisableControlAction(0, 92, true) -- Passenger Attack (Vehicle)
+ DisableControlAction(0, 99, true) -- Select Next Weapon (Vehicle)
+ DisableControlAction(0, 106, true) -- Control Override (Vehicle)
+ DisableControlAction(0, 114, true) -- Fly Attack (Flying)
+ DisableControlAction(0, 115, true) -- Next Weapon (Flying)
+ DisableControlAction(0, 121, true) -- Fly Camera (Flying)
+ DisableControlAction(0, 122, true) -- Control OVerride (Flying)
+ DisableControlAction(0, 135, true) -- Control OVerride (Sub)
+ DisableControlAction(0, 200, true) -- Pause Menu
+ DisableControlAction(0, 245, true) -- Chat
+ else
+ Wait(100)
+ end
+ end
+end)
+
+AddEventHandler('npwd:disableControlActions', function(bool)
+ disableKeys = bool
+end)
\ No newline at end of file
diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts
index 8fadd64..cbd2128 100644
--- a/resources/client/cl_main.ts
+++ b/resources/client/cl_main.ts
@@ -9,7 +9,6 @@ import { NotesEvents } from '../../typings/notes';
import { BankEvents } from '../../typings/bank';
import { PhotoEvents } from '../../typings/photo';
import { CallEvents } from '../../typings/call';
-import { MatchEvents } from '../../typings/match';
import { config } from './client';
let isPhoneOpen = false;
@@ -58,6 +57,8 @@ const showPhone = async (): Promise => {
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
sendMessage('PHONE', PhoneEvents.SET_TIME, time);
SetNuiFocus(true, true);
+ SetNuiFocusKeepInput(true);
+ emit('npwd:disableControlActions', true);
};
const hidePhone = async (): Promise => {
@@ -65,6 +66,8 @@ const hidePhone = async (): Promise => {
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
await phoneCloseAnim();
SetNuiFocus(false, false);
+ SetNuiFocusKeepInput(false);
+ emit('npwd:disableControlActions', false);
};
/* * * * * * * * * * * * *
@@ -86,6 +89,7 @@ RegisterCommand(
async () => {
await hidePhone();
sendMessage('PHONE', 'phoneRestart', {});
+ fetchOnInitialize();
},
false,
);
@@ -109,12 +113,9 @@ async function Phone(): Promise {
}
}
-// triggerd when the player is ready
-onNet(PhoneEvents.PLAYER_IS_READY, () => {
- isPlayerReady = true;
- if (isUiReady) {
- fetchOnInitialize();
- }
+// Set the global depending on the response from event
+onNet(PhoneEvents.PLAYER_IS_READY, (ready: boolean) => {
+ isPlayerReady = ready;
});
AddEventHandler('onResourceStop', function (resource: string) {
diff --git a/resources/client/cl_notes.ts b/resources/client/cl_notes.ts
index 425c9bb..fee013f 100644
--- a/resources/client/cl_notes.ts
+++ b/resources/client/cl_notes.ts
@@ -1,4 +1,4 @@
-import { NotesEvents } from '../../typings/notes';
+import { Note, NotesEvents } from '../../typings/notes';
import { sendNotesEvent } from '../utils/messages';
onNet(NotesEvents.SEND_NOTE, (notes: any) => {
@@ -6,30 +6,24 @@ onNet(NotesEvents.SEND_NOTE, (notes: any) => {
});
RegisterNuiCallbackType(NotesEvents.ADD_NOTE);
-on(`__cfx_nui:${NotesEvents.ADD_NOTE}`, (data: any) => {
- emitNet(NotesEvents.ADD_NOTE, data);
+on(`__cfx_nui:${NotesEvents.ADD_NOTE}`, (note: Note) => {
+ emitNet(NotesEvents.ADD_NOTE, note);
+});
+
+RegisterNuiCallbackType(NotesEvents.DELETE_NOTE);
+on(`__cfx_nui:${NotesEvents.DELETE_NOTE}`, (noteId: number) => {
+ emitNet(NotesEvents.DELETE_NOTE, noteId);
+});
+
+RegisterNuiCallbackType(NotesEvents.UPDATE_NOTE);
+on(`__cfx_nui:${NotesEvents.UPDATE_NOTE}`, (note: Note) => {
+ emitNet(NotesEvents.UPDATE_NOTE, note);
});
onNet(NotesEvents.SEND_NOTE_SUCCESS, () => {
emitNet(NotesEvents.FETCH_ALL_NOTES);
});
-onNet(NotesEvents.DELETE_NOTE_SUCCESS, () => {
- emitNet(NotesEvents.FETCH_ALL_NOTES);
-});
-
-RegisterNuiCallbackType(NotesEvents.DELETE_NOTE);
-on(`__cfx_nui:${NotesEvents.DELETE_NOTE}`, (data: any) => {
- emitNet(NotesEvents.DELETE_NOTE, data);
-
- emitNet(NotesEvents.FETCH_ALL_NOTES);
-});
-
-RegisterNuiCallbackType(NotesEvents.UPDATE_NOTE);
-on(`__cfx_nui:${NotesEvents.UPDATE_NOTE}`, (data: any) => {
- emitNet(NotesEvents.UPDATE_NOTE, data);
-});
-
onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => {
emitNet(NotesEvents.FETCH_ALL_NOTES);
});
@@ -37,3 +31,7 @@ onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => {
onNet(NotesEvents.ACTION_RESULT, (alert: any) => {
sendNotesEvent(NotesEvents.SEND_ALERT, alert);
});
+
+onNet(NotesEvents.DELETE_NOTE_SUCCESS, () => {
+ emitNet(NotesEvents.FETCH_ALL_NOTES);
+});
diff --git a/resources/client/cl_twitter.ts b/resources/client/cl_twitter.ts
index afd6ecb..7a72840 100644
--- a/resources/client/cl_twitter.ts
+++ b/resources/client/cl_twitter.ts
@@ -11,7 +11,7 @@ on(`__cfx_nui:${TwitterEvents.GET_OR_CREATE_PROFILE}`, () => {
});
onNet(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, (profile: any) => {
- sendTwitterMessage(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, profile);
+ sendTwitterMessage(TwitterEvents.GET_OR_CREATE_PROFILE, profile);
});
onNet(TwitterEvents.GET_OR_CREATE_PROFILE_FAILURE, () => {
@@ -61,7 +61,7 @@ on(`__cfx_nui:${TwitterEvents.FETCH_TWEETS}`, () => {
});
onNet(TwitterEvents.FETCH_TWEETS_SUCCESS, (tweets: any) => {
- sendTwitterMessage(TwitterEvents.FETCH_TWEETS_SUCCESS, tweets);
+ sendTwitterMessage(TwitterEvents.FETCH_TWEETS, tweets);
});
onNet(TwitterEvents.FETCH_TWEETS_FAILURE, () => {
diff --git a/resources/package.json b/resources/package.json
index 0fcbfb1..50acdce 100644
--- a/resources/package.json
+++ b/resources/package.json
@@ -12,6 +12,7 @@
"test": "jest"
},
"dependencies": {
+ "@discordjs/collection": "^0.1.6",
"axios": "^0.21.1",
"connection-string-parser": "^1.0.3",
"dayjs": "^1.10.4",
diff --git a/resources/server/calls/calls.controller.ts b/resources/server/calls/calls.controller.ts
new file mode 100644
index 0000000..bd9e7ee
--- /dev/null
+++ b/resources/server/calls/calls.controller.ts
@@ -0,0 +1,47 @@
+import { CallEvents } from '../../../typings/call';
+import { getSource } from '../utils/miscUtils';
+import CallService from './calls.service';
+import { callLogger } from './calls.utils';
+
+onNet(CallEvents.INITIALIZE_CALL, (receivingNumber: string) => {
+ const src = getSource();
+ CallService.handleInititializeCall(src, receivingNumber).catch((e) =>
+ callLogger.error(
+ `Error occured in intialize (${receivingNumber}) call event, Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(CallEvents.ACCEPT_CALL, (transmitterNumber: string) => {
+ const src = getSource();
+ CallService.handleAcceptCall(src, transmitterNumber).catch((e) =>
+ callLogger.error(
+ `Error occured in accept call event (${transmitterNumber}), Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(CallEvents.REJECTED, (transmitterNumber: string) => {
+ const src = getSource();
+ CallService.handleRejectCall(src, transmitterNumber).catch((e) =>
+ callLogger.error(
+ `Error occured in rejectcall event (${transmitterNumber}), Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(CallEvents.END_CALL, (transmitterNumber: string) => {
+ const src = getSource();
+ CallService.handleEndCall(src, transmitterNumber).catch((e) =>
+ callLogger.error(
+ `Error occured in end call event (${transmitterNumber}), Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(CallEvents.FETCH_CALLS, (limit?: number) => {
+ const src = getSource();
+ CallService.handleFetchCalls(src, limit).catch((e) =>
+ callLogger.error(`Error occured in fetch call event (${limit}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/calls/calls.db.ts b/resources/server/calls/calls.db.ts
new file mode 100644
index 0000000..a1d8fb2
--- /dev/null
+++ b/resources/server/calls/calls.db.ts
@@ -0,0 +1,29 @@
+import { CallHistoryItem } from '../../../typings/call';
+import { pool } from '../db';
+import { FetchDefaultLimits } from '../utils/ServerConstants';
+
+export class CallsRepo {
+ async saveCall(call: CallHistoryItem): Promise {
+ const query =
+ 'INSERT INTO npwd_calls (identifier, transmitter, receiver, `start`) VALUES (?, ?, ?, ?)';
+ await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
+ }
+
+ async updateCall(call: CallHistoryItem, isAccepted: boolean, end: number): Promise {
+ const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
+ await pool.query(query, [isAccepted, end, call.identifier]);
+ }
+
+ async fetchCalls(
+ phoneNumber: string,
+ limit = FetchDefaultLimits.CALLS_FETCH_LIMIT,
+ ): Promise {
+ const query =
+ 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC LIMIT ?';
+ const [result] = await pool.query(query, [phoneNumber, phoneNumber, limit]);
+
+ return result;
+ }
+}
+
+export default new CallsRepo();
diff --git a/resources/server/calls/calls.interfaces.ts b/resources/server/calls/calls.interfaces.ts
new file mode 100644
index 0000000..e69de29
diff --git a/resources/server/calls/calls.service.ts b/resources/server/calls/calls.service.ts
new file mode 100644
index 0000000..fe9c671
--- /dev/null
+++ b/resources/server/calls/calls.service.ts
@@ -0,0 +1,180 @@
+import Collection from '@discordjs/collection';
+import { CallEvents, CallHistoryItem } from '../../../typings/call';
+import CallsDB, { CallsRepo } from './calls.db';
+import { v4 as uuidv4 } from 'uuid';
+import PlayerService from '../players/player.service';
+import { callLogger } from './calls.utils';
+import { ContactEvents } from '../../../typings/contact';
+
+class CallsService {
+ private callMap: Collection;
+ private readonly callsDB: CallsRepo;
+
+ constructor() {
+ this.callMap = new Collection();
+ this.callsDB = CallsDB;
+ callLogger.debug('Call service started');
+ }
+
+ private setCallInMap(transmitterNumber: string, callObj: CallHistoryItem): void {
+ this.callMap.set(transmitterNumber, callObj);
+ callLogger.debug(`Call obj set with key ${transmitterNumber}, value:`);
+ callLogger.debug(callObj);
+ }
+
+ private retrieveOngoingCall(transmitterNumber: string): CallHistoryItem {
+ const obj = this.callMap.get(transmitterNumber);
+ if (!obj) {
+ throw new Error(`Call does not exist in Map with key ${transmitterNumber}`);
+ }
+ return obj;
+ }
+
+ async handleInititializeCall(src: number, receivingNumber: string): Promise {
+ // Create initial call data
+ const transmittingPlayer = PlayerService.getPlayer(src);
+ const transmitterNumber = transmittingPlayer.getPhoneNumber();
+ const startCallTimeUnix = Math.floor(new Date().getTime() / 1000);
+ const callIdentifier = uuidv4();
+
+ const receiverIdentifier = await PlayerService.getIdentifierFromPhoneNumber(
+ receivingNumber,
+ true,
+ );
+ // Will be null if the player is offline
+ const receivingPlayer = PlayerService.getPlayerFromIdentifier(receiverIdentifier);
+
+ callLogger.debug(`Receiving Identifier: ${receiverIdentifier}`);
+ callLogger.debug(`Receiving source: ${receivingPlayer.source} `);
+
+ const callObj: CallHistoryItem = {
+ identifier: callIdentifier,
+ transmitter: transmitterNumber,
+ transmitterSource: transmittingPlayer.source,
+ receiver: receivingNumber,
+ receiverSource: receivingPlayer.source,
+ start: startCallTimeUnix,
+ accepted: false,
+ };
+
+ if (!receivingPlayer) {
+ // TODO: handle offline player
+
+ // FIXME: Add actual localization for this.
+ emitNet(CallEvents.ACTION_RESULT, src, {
+ message: 'Could not reach player',
+ type: 'error',
+ });
+ return;
+ }
+
+ this.setCallInMap(callObj.transmitter, callObj);
+
+ await this.callsDB
+ .saveCall(callObj)
+ .catch((e) =>
+ callLogger.error(
+ `Unable to save call object for transmitter number ${transmitterNumber}. Error: ${e.message}`,
+ ),
+ );
+
+ emitNet(CallEvents.START_CALL, src, transmitterNumber, receivingNumber, true);
+ emitNet(
+ CallEvents.START_CALL,
+ receivingPlayer.source,
+ transmitterNumber,
+ receivingNumber,
+ false,
+ );
+ }
+
+ async handleAcceptCall(src: number, transmitterNumber: string): Promise {
+ // We retrieve the call that was accepted from the current calls map
+ const curCallAccepted = this.callMap.get(transmitterNumber);
+ // We update its reference
+ curCallAccepted.accepted = true;
+
+ const channelId = src;
+
+ await this.callsDB.saveCall(curCallAccepted);
+ callLogger.debug(`Call with key ${transmitterNumber} was updated to be accepted`);
+
+ // player who is being called
+ emitNet(
+ CallEvents.WAS_ACCEPTED,
+ curCallAccepted.receiverSource,
+ channelId,
+ curCallAccepted,
+ false,
+ );
+ // player who is calling
+ emitNet(
+ CallEvents.WAS_ACCEPTED,
+ curCallAccepted.transmitterSource,
+ channelId,
+ curCallAccepted,
+ true,
+ );
+ }
+
+ async handleFetchCalls(src: number, limit: number): Promise {
+ const player = PlayerService.getPlayer(src);
+
+ const calls = await this.callsDB.fetchCalls(player.getPhoneNumber(), limit);
+ emitNet(CallEvents.FETCH_CALLS, src, calls);
+ }
+
+ async handleRejectCall(src: number, transmitterNumber: string): Promise {
+ const currentCall = this.callMap.get(transmitterNumber);
+
+ const endCallTimeUnix = Math.floor(new Date().getTime() / 1000);
+
+ if (!currentCall) {
+ callLogger.error(
+ `Call with transmitter number ${transmitterNumber} does not exist in current calls map!`,
+ );
+ return;
+ }
+
+ // player who is called and initiasted the rejection.
+ emitNet(CallEvents.WAS_REJECTED, currentCall.receiverSource);
+
+ // player who is calling and recieved the rejection.
+ emitNet(CallEvents.WAS_REJECTED, currentCall.transmitterSource);
+
+ await this.callsDB.updateCall(currentCall, false, endCallTimeUnix);
+
+ this.callMap.delete(transmitterNumber);
+ }
+
+ async handleEndCall(src: number, transmitterNumber: string) {
+ const endCallTimeUnix = Math.floor(new Date().getTime() / 1000);
+
+ const currentCall = this.callMap.get(transmitterNumber);
+
+ if (!currentCall) {
+ callLogger.error(
+ `Call with transmitter number ${transmitterNumber} does not exist in current calls map!`,
+ );
+ return;
+ }
+
+ // player who is being called
+ emitNet(CallEvents.WAS_ENDED, currentCall.receiverSource);
+ // player who is calling
+ emitNet(CallEvents.WAS_ENDED, currentCall.transmitterSource);
+
+ // ends animations if call is active
+ // TODO: This animation flow needs to be taken a look at. We should be able to
+ // to just attach this to the WAS_ENDED event without another net event.
+ if (currentCall.accepted) {
+ emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.receiverSource);
+ emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.transmitterSource);
+ }
+
+ // Clear from memory
+ this.callMap.delete(transmitterNumber);
+ }
+}
+
+export default new CallsService();
diff --git a/resources/server/calls/calls.utils.ts b/resources/server/calls/calls.utils.ts
new file mode 100644
index 0000000..fe50407
--- /dev/null
+++ b/resources/server/calls/calls.utils.ts
@@ -0,0 +1,3 @@
+import { mainLogger } from '../sv_logger';
+
+export const callLogger = mainLogger.child({ module: 'calls' });
diff --git a/resources/server/contacts/contacts.controller.ts b/resources/server/contacts/contacts.controller.ts
new file mode 100644
index 0000000..1e46f82
--- /dev/null
+++ b/resources/server/contacts/contacts.controller.ts
@@ -0,0 +1,32 @@
+import { Contact, ContactEvents, PreDBContact } from '../../../typings/contact';
+import { getSource } from '../utils/miscUtils';
+import ContactService from './contacts.service';
+import { contactsLogger } from './contacts.utils';
+
+onNet(ContactEvents.GET_CONTACTS, async (limit: number) => {
+ const src = getSource();
+ ContactService.handleFetchContact(src, limit).catch((e) =>
+ contactsLogger.error(`Error occured in fetch contacts event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(ContactEvents.ADD_CONTACT, async (contact: PreDBContact) => {
+ const src = getSource();
+ ContactService.handleAddContact(src, contact).catch((e) =>
+ contactsLogger.error(`Error occured in fetch contacts event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(ContactEvents.UPDATE_CONTACT, async (contact: Contact) => {
+ const src = getSource();
+ ContactService.handleUpdateContact(src, contact).catch((e) =>
+ contactsLogger.error(`Error occured in update contact event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(ContactEvents.DELETE_CONTACT, async (contactId: number) => {
+ const src = getSource();
+ ContactService.handleDeleteContact(src, contactId).catch((e) =>
+ contactsLogger.error(`Error occured in delete contact event (${src}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/contacts/contacts.db.ts b/resources/server/contacts/contacts.db.ts
new file mode 100644
index 0000000..7d3c742
--- /dev/null
+++ b/resources/server/contacts/contacts.db.ts
@@ -0,0 +1,42 @@
+import { pool } from '../db';
+import { Contact, PreDBContact } from '../../../typings/contact';
+import { FetchDefaultLimits } from '../utils/ServerConstants';
+
+export class _ContactsDB {
+ async fetchAllContacts(
+ identifier: string,
+ limit = FetchDefaultLimits.CONTACTS_FETCH_LIMIT,
+ ): Promise {
+ const query =
+ 'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC LIMIT ?';
+ const [results] = await pool.query(query, [identifier, limit]);
+ return results;
+ }
+
+ async addContact(identifier: string, { display, avatar, number }: PreDBContact): Promise {
+ const query =
+ 'INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)';
+
+ await pool.query(query, [identifier, number, display, avatar]);
+ }
+
+ async updateContact(contact: Contact, identifier: string): Promise {
+ const query =
+ 'UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?';
+ await pool.query(query, [
+ contact.number,
+ contact.display,
+ contact.avatar,
+ contact.id,
+ identifier,
+ ]);
+ }
+
+ async deleteContact(contactId: number, identifier: string): Promise {
+ const query = 'DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?';
+ await pool.query(query, [contactId, identifier]);
+ }
+}
+
+const ContactsDB = new _ContactsDB();
+export default ContactsDB;
diff --git a/resources/server/contacts/contacts.interfaces.ts b/resources/server/contacts/contacts.interfaces.ts
new file mode 100644
index 0000000..0b41b01
--- /dev/null
+++ b/resources/server/contacts/contacts.interfaces.ts
@@ -0,0 +1,8 @@
+import { FxServerRespError } from '../../../typings/phone';
+import { ContactEvents } from '../../../typings/contact';
+
+export interface ContactServerResp {
+ data?: unknown;
+ error?: FxServerRespError;
+ action: ContactEvents;
+}
diff --git a/resources/server/contacts/contacts.service.ts b/resources/server/contacts/contacts.service.ts
new file mode 100644
index 0000000..a756e58
--- /dev/null
+++ b/resources/server/contacts/contacts.service.ts
@@ -0,0 +1,95 @@
+import PlayerService from '../players/player.service';
+import { contactsLogger } from './contacts.utils';
+import ContactsDB, { _ContactsDB } from './contacts.db';
+import { Contact, ContactEvents, PreDBContact } from '../../../typings/contact';
+import { ErrorStringKeys, FxServerResponse } from '../../../typings/phone';
+import { ContactServerResp } from './contacts.interfaces';
+
+class _ContactService {
+ private readonly contactsDB: _ContactsDB;
+
+ constructor() {
+ this.contactsDB = ContactsDB;
+ contactsLogger.debug('Contacts service started');
+ }
+
+ private responseBuilder(src: number, { data, action, error }: ContactServerResp): void {
+ const serverRespObj: FxServerResponse = {
+ app: 'CONTACTS',
+ error,
+ status: data ? 'success' : 'failure',
+ action,
+ };
+
+ emitNet(ContactEvents.MAIN_CLIENT_LISTER, src, serverRespObj);
+ }
+
+ async handleUpdateContact(src: number, contact: Contact): Promise {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.contactsDB.updateContact(contact, identifier);
+
+ emitNet(ContactEvents.UPDATE_CONTACT_SUCCESS, src);
+
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_UPDATE_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ contactsLogger.error(`Error in handleUpdateContact (${identifier}), ${e.message}`);
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_UPDATE_FAILED',
+ type: 'error',
+ });
+ }
+ }
+ async handleDeleteContact(src: number, contactId: number): Promise {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.contactsDB.deleteContact(contactId, identifier);
+ emitNet(ContactEvents.DELETE_CONTACT_SUCCESS, src);
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_DELETE_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_DELETE_FAILED',
+ type: 'error',
+ });
+ contactsLogger.error(`Error in handleDeleteContact (${identifier}), ${e.message}`);
+ }
+ }
+ async handleAddContact(src: number, contact: PreDBContact): Promise {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.contactsDB.addContact(identifier, contact);
+
+ emitNet(ContactEvents.ADD_CONTACT_SUCCESS, src);
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_ADD_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ contactsLogger.error(`Error in handleAddContact, ${e.message}`);
+ emitNet(ContactEvents.ACTION_RESULT, src, {
+ message: 'CONTACT_ADD_FAILED',
+ type: 'error',
+ });
+ }
+ }
+ async handleFetchContact(src: number, limit?: number): Promise {
+ const identifier = PlayerService.getIdentifier(src);
+
+ try {
+ const contacts = await this.contactsDB.fetchAllContacts(identifier, limit);
+
+ emitNet(ContactEvents.SEND_CONTACTS, src, contacts);
+ } catch (e) {
+ contactsLogger.error(`Error in handleFetchContact (${identifier}), ${e.message}`);
+ }
+ }
+}
+
+const ContactService = new _ContactService();
+export default ContactService;
diff --git a/resources/server/contacts/contacts.utils.ts b/resources/server/contacts/contacts.utils.ts
new file mode 100644
index 0000000..0f0c69d
--- /dev/null
+++ b/resources/server/contacts/contacts.utils.ts
@@ -0,0 +1,3 @@
+import { mainLogger } from '../sv_logger';
+
+export const contactsLogger = mainLogger.child({ module: 'contact' });
diff --git a/resources/server/functions.ts b/resources/server/functions.ts
index b406ebc..1039f99 100644
--- a/resources/server/functions.ts
+++ b/resources/server/functions.ts
@@ -1,96 +1,37 @@
import { pool } from './db';
import { config } from './server';
import { mainLogger } from './sv_logger';
-import { Player, Players, PlayersByIdentifier } from './players/sv_players';
-
-export function getPlayer(source: number): Player {
- const player = Players.get(source);
- if (!player) mainLogger.error(`Could not find player from source: ${source}`);
- return player;
-}
-
-export const getSource = () => (global as any).source;
-
-// we might need to run a db query on this.
-// to make it more standalone
-/**
- * Return the identifier for an online player
- * @param source The source/netId for the player in question
- **/
-export function getIdentifier(source: number): string {
- return getPlayer(source).identifier;
-}
-
-/**
- * Return the attached identifier for a given phone number
- * @param phoneNumber The phone number to return identifier for
- * @param fetch Whether or not to query the database if a given player is offline
- **/
-export async function getIdentifierByPhoneNumber(
- phoneNumber: string,
- fetch?: boolean,
-): Promise {
- for (const [source, player] of Players) {
- if (player.getPhoneNumber() === phoneNumber) return player.identifier;
- }
- // Whether we fetch from database if not found in online players
- if (fetch) {
- const query = `SELECT identifier FROM users WHERE phone_number = ?`;
- const [results] = await pool.query(query, [phoneNumber]);
- // Get identifier from results
- return (results as { identifier: string }[])[0].identifier;
- }
- return null;
-}
-
-/**
- * Returns the player phoneNumber for a passed identifier
- * @param identifier The players phone number
- */
-export function getPlayerFromIdentifier(identifier: string): Player | null {
- const player = PlayersByIdentifier.get(identifier);
- if (!player) return null;
- return player;
-}
-
-function getRandomPhoneNumber() {
- let randomNumber: string = null;
-
- if (!config.general.useDashNumber) {
- randomNumber = Math.floor(Math.random() * 10000000).toString(); // 10000000 creates a number with 7 characters.
- } else {
- randomNumber = Math.floor(Math.random() * 10000000)
- .toString()
- .replace(/(\d{3})(\d{4})/, '$1-$2');
- // The numbers inside {} in replace() can be changed to how many digits you want on each side of the dash.
- // Example: 123-4567
- }
- mainLogger.debug(`Getting random number: ${randomNumber}`);
-
- return randomNumber;
-}
+import { getRandomPhoneNumber } from './utils/getRandomPhoneNumber';
+import PlayerService from './players/player.service';
export async function generatePhoneNumber(identifier: string): Promise {
- const getQuery = `SELECT phone_number FROM users WHERE identifier = ?`;
+ const getQuery = `SELECT phone_number FROM ${config.database.playerTable} WHERE ${config.database.identifierColumn} = ?`;
const [results] = await pool.query(getQuery, [identifier]);
const result = results;
const phoneNumber = result[0]?.phone_number;
- if (!phoneNumber) {
- let existingId;
- let newNumber;
- do {
- newNumber = getRandomPhoneNumber();
- try {
- existingId = await getIdentifierByPhoneNumber(newNumber);
- } catch (e) {
- existingId = false;
- }
- } while (existingId);
- mainLogger.debug(`Inserting number into Database: ${newNumber}`);
- const query = 'UPDATE users SET phone_number = ? WHERE identifier = ?';
- await pool.query(query, [newNumber, identifier]);
- return newNumber;
- }
+ // Generate a new phone number if there isn't one present
+ if (!phoneNumber)
+ if (!phoneNumber) {
+ let existingId;
+ let newNumber;
+
+ do {
+ newNumber = getRandomPhoneNumber();
+ try {
+ existingId = await PlayerService.getIdentifierByPhoneNumber(newNumber);
+ } catch (e) {
+ existingId = false;
+ }
+ } while (existingId);
+
+ mainLogger.debug(
+ `Generated a new number for identifier: ${identifier}, number: ${phoneNumber}`,
+ );
+ const query = `UPDATE ${config.database.playerTable} SET phone_number = ? WHERE ${config.database.identifierColumn} = ?`;
+ await pool.query(query, [newNumber, identifier]);
+ return newNumber;
+ }
+
return phoneNumber;
}
diff --git a/resources/server/marketplace/marketplace.controller.ts b/resources/server/marketplace/marketplace.controller.ts
new file mode 100644
index 0000000..2e6caf6
--- /dev/null
+++ b/resources/server/marketplace/marketplace.controller.ts
@@ -0,0 +1,43 @@
+import { MarketplaceEvents, MarketplaceListing } from '../../../typings/marketplace';
+import { getSource } from '../utils/miscUtils';
+import PlayerService from '../players/player.service';
+import { reportListingToDiscord } from '../discord';
+import { selloutLogger } from './marketplace.utils';
+import MarketplaceService from './marketplace.service';
+
+onNet(MarketplaceEvents.FETCH_LISTING, async () => {
+ const src = getSource();
+ MarketplaceService.handleFetchListings(src).catch((e) =>
+ selloutLogger.error(`Error occurred in fetch listing event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(MarketplaceEvents.ADD_LISTING, async (listing: MarketplaceListing) => {
+ const src = getSource();
+ const Player = PlayerService.getPlayer(src);
+
+ MarketplaceService.handleAddListing(
+ src,
+ Player.getFirstName(),
+ Player.username,
+ Player.getName(),
+ Player.getPhoneNumber(),
+ listing,
+ ).catch((e) =>
+ selloutLogger.error(`Error occurred in add listing event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(MarketplaceEvents.DELETE_LISTING, async (listingId: number) => {
+ const src = getSource();
+ MarketplaceService.handleDeleteListing(src, listingId).catch((e) =>
+ selloutLogger.error(`Error occurred in delete listing event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(MarketplaceEvents.REPORT_LISTING, async (listing: MarketplaceListing) => {
+ const src = getSource();
+ MarketplaceService.handleReportListing(src, listing).catch((e) =>
+ selloutLogger.error(`Error occurred in report listing event (${src}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/marketplace/marketplace.db.ts b/resources/server/marketplace/marketplace.db.ts
new file mode 100644
index 0000000..f449fbe
--- /dev/null
+++ b/resources/server/marketplace/marketplace.db.ts
@@ -0,0 +1,62 @@
+import { pool } from '../db';
+import { MarketplaceListing } from '../../../typings/marketplace';
+
+export class _MarketplaceDB {
+ async addListing(
+ identifier: string,
+ username: string,
+ name: string,
+ number: any,
+ listing: MarketplaceListing,
+ ): Promise {
+ const query =
+ 'INSERT INTO npwd_marketplace_listings (identifier, username, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?, ?)';
+
+ await pool.query(query, [
+ identifier,
+ username,
+ name,
+ number,
+ listing.title,
+ listing.url,
+ listing.description,
+ ]);
+ }
+
+ async fetchListings(): Promise {
+ const query = 'SELECT * FROM npwd_marketplace_listings ORDER BY id DESC';
+
+ const [results] = await pool.query(query);
+ return results;
+ }
+
+ async deleteListing(listingId: number, identifier: string): Promise {
+ const query = 'DELETE FROM npwd_marketplace_listings WHERE id = ? AND identifier = ?';
+
+ await pool.query(query, [listingId, identifier]);
+ }
+
+ async getListing(listingId: number): Promise {
+ const query = `SELECT * FROM npwd_marketplace_listings WHERE id = ?`;
+ const [results] = await pool.query(query, [listingId]);
+ const listings = results;
+ return listings[0];
+ }
+
+ async reportListing(listingId: number, profile: string): Promise {
+ const query = `INSERT INTO npwd_marketplace_reports (listing_id, profile) VALUES (?, ?)`;
+ await pool.query(query, [listingId, profile]);
+ }
+
+ async doesReportExist(listingId: number, profile: string): Promise {
+ const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`;
+ const [results] = await pool.query(query, [listingId, profile]);
+ const result = results;
+
+ return result.length > 0;
+ }
+}
+
+const MarketplaceDB = new _MarketplaceDB();
+
+export default MarketplaceDB;
diff --git a/resources/server/marketplace/marketplace.service.ts b/resources/server/marketplace/marketplace.service.ts
new file mode 100644
index 0000000..92a726e
--- /dev/null
+++ b/resources/server/marketplace/marketplace.service.ts
@@ -0,0 +1,110 @@
+import PlayerService from '../players/player.service';
+import { selloutLogger } from './marketplace.utils';
+import MarketplaceDB, { _MarketplaceDB } from './marketplace.db';
+import { MarketplaceEvents, MarketplaceListing } from '../../../typings/marketplace';
+import { notesLogger } from '../notes/notes.utils';
+import { listenerCount } from 'cluster';
+import { reportListingToDiscord } from '../discord';
+
+class _MarketplaceService {
+ private readonly marketplaceDB: _MarketplaceDB;
+
+ constructor() {
+ this.marketplaceDB = MarketplaceDB;
+ selloutLogger.debug('Marketplace service started');
+ }
+
+ async handleAddListing(
+ src: number,
+ identifier: string,
+ username: string,
+ name: string,
+ number: any,
+ listing: MarketplaceListing,
+ ): Promise {
+ selloutLogger.debug('Handling add listing, listing:');
+ selloutLogger.debug;
+
+ try {
+ await this.marketplaceDB.addListing(identifier, username, name, number, listing);
+
+ emitNet(MarketplaceEvents.ADD_LISTING_SUCCESS, src);
+ emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_CREATE_LISTING_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ selloutLogger.error(`Failed to add listing ${e.message}`, {
+ source: src,
+ });
+
+ emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_CREATE_LISTING_FAILED',
+ type: 'error',
+ });
+ }
+ }
+
+ async handleFetchListings(src: number) {
+ try {
+ const listings = await this.marketplaceDB.fetchListings();
+
+ emitNet(MarketplaceEvents.SEND_LISTING, src, listings);
+ } catch (e) {
+ selloutLogger.error(`Failed to fetch listings, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+
+ async handleDeleteListing(src: number, listingId: number): Promise {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.marketplaceDB.deleteListing(listingId, identifier);
+
+ emitNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, src);
+ emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_DELETE_LISTING_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ notesLogger.error(`Error in handleDeleteListing, ${e.message}`);
+
+ emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_DELETE_LISTING_FAILED',
+ type: 'error',
+ });
+ }
+ }
+
+ async handleReportListing(src: number, listing: MarketplaceListing): Promise {
+ try {
+ const rListing = await this.marketplaceDB.getListing(listing.id);
+ const reportExists = await this.marketplaceDB.doesReportExist(listing.id, listing.name);
+
+ const reportingPlayer = GetPlayerName(src.toString());
+ if (reportExists) {
+ selloutLogger.error(`This listing has already been reported`);
+ return emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_REPORT_LISTING_FAILED',
+ type: 'info',
+ });
+ }
+
+ await this.marketplaceDB.reportListing(rListing.id, rListing.name);
+ await reportListingToDiscord(rListing, reportingPlayer);
+
+ emitNet(MarketplaceEvents.ACTION_RESULT, src, {
+ message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ selloutLogger.error(`Failed to report listing ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+}
+
+const MarketplaceService = new _MarketplaceService();
+export default MarketplaceService;
diff --git a/resources/server/marketplace/marketplace.utils.ts b/resources/server/marketplace/marketplace.utils.ts
new file mode 100644
index 0000000..54cb221
--- /dev/null
+++ b/resources/server/marketplace/marketplace.utils.ts
@@ -0,0 +1,3 @@
+import { mainLogger } from '../sv_logger';
+
+export const selloutLogger = mainLogger.child({ module: 'sellout' });
diff --git a/resources/server/messages/messages.controller.ts b/resources/server/messages/messages.controller.ts
new file mode 100644
index 0000000..4e14b86
--- /dev/null
+++ b/resources/server/messages/messages.controller.ts
@@ -0,0 +1,43 @@
+import { getSource } from '../utils/miscUtils';
+import { MessageEvents } from '../../../typings/messages';
+import MessagesService from './messages.service';
+import { messagesLogger } from './messages.utils';
+
+onNet(MessageEvents.FETCH_MESSAGE_GROUPS, async () => {
+ const src = getSource();
+ MessagesService.handleFetchMessageGroups(src).catch((e) =>
+ messagesLogger.error(
+ `Error occurred in fetch messag group event (${src}), Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(MessageEvents.CREATE_MESSAGE_GROUP, async (phoneNumbers: string[], label: string = null) => {
+ const src = getSource();
+ MessagesService.handleCreateMessageGroup(src, phoneNumbers, label).catch((e) =>
+ messagesLogger.error(
+ `Error occurred in create message group event (${src}), Error: ${e.message}`,
+ ),
+ );
+});
+
+onNet(MessageEvents.FETCH_MESSAGES, async (groupId: string) => {
+ const src = getSource();
+ MessagesService.handleFetchMessages(src, groupId).catch((e) =>
+ messagesLogger.error(`Error occurred in fetch messages event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(MessageEvents.SEND_MESSAGE, async (groupId: string, message: string, groupName: string) => {
+ const src = getSource();
+ MessagesService.handleSendMessage(src, groupId, message, groupName).catch((e) =>
+ messagesLogger.error(`Error occurred in send message event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(MessageEvents.SET_MESSAGE_READ, async (groupId: string) => {
+ const src = getSource();
+ MessagesService.handleSetMessageRead(src, groupId).catch((e) =>
+ messagesLogger.error(`Error occurred in set message read event (${src}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/messages/messages.db.ts b/resources/server/messages/messages.db.ts
new file mode 100644
index 0000000..29aa5a4
--- /dev/null
+++ b/resources/server/messages/messages.db.ts
@@ -0,0 +1,195 @@
+import { pool } from '../db';
+import { UnformattedMessageGroup, Message } from '../../../typings/messages';
+
+export class _MessagesDB {
+ /**
+ * Create a message in the database
+ * @param userIdentifier - identifier of the user creating this message
+ * @param groupId - the message group ID to attach this message to
+ * @param message - content of the message
+ * @param participants -
+ */
+ async createMessage(
+ userIdentifier: string,
+ groupId: string,
+ message: string,
+ participants: string[],
+ ): Promise {
+ const query = `INSERT INTO npwd_messages (user_identifier, message, group_id) VALUES (?, ?, ?)`;
+
+ const groupQuery = `
+ UPDATE npwd_messages_groups SET unreadCount = unreadCount + 1 WHERE participant_identifier = ? AND group_id = ?
+ `;
+ const [results] = await pool.query(query, [userIdentifier, message, groupId]);
+
+ await Promise.all(
+ participants
+ .filter((s) => userIdentifier !== s)
+ .map((s) => pool.query(groupQuery, [s, groupId])),
+ );
+
+ return results;
+ }
+
+ /**
+ * Retrieve all message groups associated with a user. This will
+ * populate the list of message groups on the UI
+ * @param userIdentifier - identifier of the user to get message groups for
+ */
+ async getMessageGroups(userIdentifier: string): Promise {
+ const query = `
+ SELECT
+ npwd_messages_groups.unreadCount,
+ npwd_messages_groups.group_id,
+ npwd_messages_groups.participant_identifier,
+ npwd_messages_groups.user_identifier,
+ npwd_messages_labels.label,
+ users.phone_number,
+ npwd_phone_contacts.avatar,
+ npwd_phone_contacts.display
+ FROM (
+ SELECT group_id
+ FROM npwd_messages_groups
+ WHERE npwd_messages_groups.participant_identifier = ?
+ ) as t
+ LEFT OUTER JOIN npwd_messages_groups on npwd_messages_groups.group_id = t.group_id
+ LEFT OUTER JOIN users on users.identifier = npwd_messages_groups.participant_identifier
+ LEFT OUTER JOIN npwd_messages_labels on npwd_messages_labels.group_id = npwd_messages_groups.group_id
+ LEFT OUTER JOIN npwd_phone_contacts on REGEXP_REPLACE(npwd_phone_contacts.number, '[^0-9]', '') = REGEXP_REPLACE(users.phone_number, '[^0-9]', '') AND npwd_phone_contacts.identifier = ?
+ ORDER BY npwd_messages_groups.createdAt DESC
+ `;
+
+ const [results] = await pool.query(query, [userIdentifier, userIdentifier, userIdentifier]);
+ return results;
+ }
+
+ /**
+ * Retrieve all messages associated with a group and add a field
+ * "isMine" which determines if the message belongs to the user
+ * making the request
+ * @param userIdentifier - user to get messages for
+ * @param groupId - the group to get messages from
+ */
+ async getMessages(userIdentifier: string, groupId: string): Promise {
+ const query = `
+ SELECT
+ npwd_messages.id,
+ npwd_messages.message,
+ npwd_messages.group_id,
+ npwd_messages.user_identifier,
+ npwd_messages.isRead,
+ npwd_messages.updatedAt,
+ users.phone_number,
+ npwd_phone_contacts.display,
+ npwd_phone_contacts.avatar
+ FROM npwd_messages
+ LEFT OUTER JOIN users on users.identifier = npwd_messages.user_identifier
+ LEFT OUTER JOIN npwd_phone_contacts on REGEXP_REPLACE(npwd_phone_contacts.number, '[^0-9]', '') = REGEXP_REPLACE(users.phone_number, '[^0-9]', '') AND npwd_phone_contacts.identifier = ?
+ WHERE npwd_messages.group_id = ?
+ ORDER BY createdAt ASC;
+ `;
+
+ const [results] = await pool.query(query, [userIdentifier, groupId]);
+ const messages = results;
+ return messages.map((message) => ({
+ ...message,
+ isMine: message.user_identifier == userIdentifier,
+ updatedAt: message.updatedAt.toString(),
+ }));
+ }
+
+ /**
+ * Create a message group label
+ * @param userIdentifier - user who is creating the message group
+ * @param groupId - groupId this label is attached to
+ * @param label - the label itself
+ */
+ async createLabel(userIdentifier: string, groupId: string, label: string): Promise {
+ const query = `
+ INSERT INTO npwd_messages_labels
+ (user_identifier, group_id, label)
+ VALUES (?, ?, ?)
+ `;
+ await pool.query(query, [userIdentifier, groupId, label]);
+ }
+
+ /**
+ * Create a message group
+ * @param userIdentifier - the user creating the message group
+ * @param groupId - the unique group ID this corresponds to
+ * @param participantIdentifier - the participant user identifier. This identifier is what attaches
+ * other players to the message group
+ */
+ async createMessageGroup(
+ userIdentifier: string,
+ groupId: string,
+ participantIdentifier: string,
+ ): Promise {
+ const query = `
+ INSERT INTO npwd_messages_groups
+ (user_identifier, group_id, participant_identifier)
+ VALUES (?, ?, ?)
+ `;
+ await pool.query(query, [userIdentifier, groupId, participantIdentifier]);
+ }
+
+ /**
+ * Find a players identifier from their phone number
+ * @param phoneNumber - the phone number to search for
+ */
+ async getIdentifierFromPhoneNumber(phoneNumber: string): Promise {
+ const query = `
+ SELECT identifier
+ FROM users
+ WHERE REGEXP_REPLACE(phone_number, '[^0-9]', '') = ?
+ LIMIT 1
+ `;
+ const [results] = await pool.query(query, [phoneNumber]);
+ const identifiers = results;
+ return identifiers[0]['identifier'];
+ }
+
+ /**
+ * This method checks if the input groupId already exists in
+ * the database. As long as the groupId is derived from the input
+ * identifiers this means that the user is trying to create a
+ * duplicate!
+ * @param groupId - group Id to check that it exists
+ */
+ async checkIfMessageGroupExists(groupId: string): Promise {
+ const query = `
+ SELECT COUNT(*) as count
+ FROM npwd_messages_groups
+ WHERE group_id = ?;
+ `;
+ const [results] = await pool.query(query, [groupId]);
+ const result = results;
+ const count = result[0].count;
+ return count > 0;
+ }
+
+ async getMessageCountByGroup(groupId: string): Promise {
+ const query = `
+ SELECT COUNT(*) as count
+ FROM npwd_messages
+ WHERE group_id = ?;
+ `;
+ const [results] = await pool.query(query, [groupId]);
+ const result = results;
+ return result[0].count;
+ }
+
+ /**
+ * Sets the current message isRead to 0 for said player
+ * @param groupId The unique group ID for the message
+ * @param identifier The identifier for the player
+ */
+ async setMessageRead(groupId: string, identifier: string) {
+ const query = `UPDATE npwd_messages_groups SET unreadCount = 0 WHERE group_id = ? AND participant_identifier = ?`;
+ await pool.query(query, [groupId, identifier]);
+ }
+}
+
+const MessagesDB = new _MessagesDB();
+
+export default MessagesDB;
diff --git a/resources/server/messages/messages.service.ts b/resources/server/messages/messages.service.ts
new file mode 100644
index 0000000..e57e306
--- /dev/null
+++ b/resources/server/messages/messages.service.ts
@@ -0,0 +1,162 @@
+import PlayerService from '../players/player.service';
+import { MessageEvents } from '../../../typings/messages';
+import MessagesDB, { _MessagesDB } from './messages.db';
+import {
+ createMessageGroupsFromPhoneNumbers,
+ getFormattedMessageGroups,
+ getIdentifiersFromParticipants,
+ messagesLogger,
+} from './messages.utils';
+
+class _MessagesService {
+ private readonly messagesDB: _MessagesDB;
+
+ constructor() {
+ this.messagesDB = MessagesDB;
+ messagesLogger.debug('Messages service started');
+ }
+
+ async handleFetchMessageGroups(src: number) {
+ try {
+ const identifier = PlayerService.getIdentifier(src);
+ const messageGroups = await getFormattedMessageGroups(identifier);
+ emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS, src, messageGroups);
+ } catch (e) {
+ emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_FAILED, src);
+ messagesLogger.error(`Failed to fetch messages groups, ${e.message}`);
+ }
+ }
+
+ async handleCreateMessageGroup(src: number, phoneNumbers: string[], label: string = null) {
+ try {
+ const _identifier = PlayerService.getIdentifier(src);
+ const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
+
+ if (result.error && result.allNumbersFailed) {
+ emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, src, result);
+ return emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_ALL_NUMBERS_FAILED`,
+ type: 'error',
+ });
+ }
+
+ if (result.error) {
+ emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, src, result);
+ return emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED`,
+ type: 'error',
+ });
+ }
+
+ if (result.failedNumbers.length === 1) {
+ emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_ONE_NUMBER_FAILED`,
+ type: 'warning',
+ options: { number: result.failedNumbers[0] },
+ });
+ }
+
+ if (result.failedNumbers.length > 1) {
+ emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_SOME_NUMBERS_FAILED`,
+ type: 'warning',
+ options: { numbers: result.failedNumbers.join(', ') },
+ });
+ }
+
+ emitNet(MessageEvents.CREATE_MESSAGE_GROUP_SUCCESS, src, result);
+ if (result.duplicate) {
+ return;
+ }
+
+ if (result.identifiers) {
+ for (const participantId of result.identifiers) {
+ // we don't broadcast to the source of the event.
+ if (participantId !== _identifier) {
+ const participantPlayer = PlayerService.getPlayerFromIdentifier(participantId);
+ if (!participantPlayer) {
+ return;
+ }
+ emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, participantPlayer.source);
+ }
+ }
+ }
+ } catch (e) {
+ emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, src);
+ emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED`,
+ type: 'error',
+ });
+ messagesLogger.error(`Failed to create message group, ${e.message}`, {
+ source: src,
+ e,
+ });
+ }
+ }
+
+ async handleFetchMessages(src: number, groupId: string) {
+ try {
+ const _identifier = PlayerService.getIdentifier(src);
+ const messages = await this.messagesDB.getMessages(_identifier, groupId);
+ emitNet(MessageEvents.FETCH_MESSAGES_SUCCESS, src, messages);
+ } catch (e) {
+ emitNet(MessageEvents.FETCH_MESSAGES_FAILED, src);
+ messagesLogger.error(`Failed to fetch messages, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+
+ async handleSendMessage(src: number, groupId: string, message: string, groupName: string) {
+ try {
+ const _identifier = PlayerService.getIdentifier(src);
+ const userParticipants = getIdentifiersFromParticipants(groupId);
+
+ await this.messagesDB.createMessage(_identifier, groupId, message, userParticipants);
+
+ emitNet(MessageEvents.SEND_MESSAGE_SUCCESS, src, groupId);
+
+ // gets the identifiers foe the participants for current groupId.
+
+ for (const participantId of userParticipants) {
+ // we don't broadcast to the source of the event.
+ if (participantId !== _identifier) {
+ const participantPlayer = PlayerService.getPlayerFromIdentifier(participantId);
+ if (!participantPlayer) {
+ return;
+ }
+ emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, participantPlayer.source);
+ emitNet(MessageEvents.CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
+ groupName,
+ groupId,
+ message,
+ });
+ }
+ }
+ } catch (e) {
+ emitNet(MessageEvents.ACTION_RESULT, src, {
+ message: 'APPS_MESSAGES_NEW_MESSAGE_FAILED',
+ type: 'error',
+ });
+ messagesLogger.error(`Failed to send message, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+
+ async handleSetMessageRead(src: number, groupId: string) {
+ try {
+ const identifier = PlayerService.getIdentifier(src);
+ await this.messagesDB.setMessageRead(groupId, identifier);
+ emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, src);
+ } catch (e) {
+ messagesLogger.error(`Failed to set message as read, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+}
+
+const MessagesService = new _MessagesService();
+
+export default MessagesService;
diff --git a/resources/server/messages/messages.utils.ts b/resources/server/messages/messages.utils.ts
new file mode 100644
index 0000000..131d8c0
--- /dev/null
+++ b/resources/server/messages/messages.utils.ts
@@ -0,0 +1,201 @@
+import { withTransaction } from '../db';
+import {
+ CreateMessageGroupResult,
+ MessageGroup,
+ MessageGroupMapping,
+ UnformattedMessageGroup,
+} from '../../../typings/messages';
+import { mainLogger } from '../sv_logger';
+import MessagesDB from './messages.db';
+
+export const messagesLogger = mainLogger.child({ module: 'messages' });
+
+// Functions
+
+/**
+ * Consolidate raw message groups into a mapping that groups participants
+ * by the message group. The goal of this is to reduce the rows of message
+ * groups into a single MessageGroup object.
+ * @param userIdentifier - the user identifier to get message groups for
+ */
+export async function getConsolidatedMessageGroups(
+ userIdentifier: string,
+): Promise {
+ const messageGroups = await MessagesDB.getMessageGroups(userIdentifier);
+ return messageGroups.reduce(
+ (mapping: MessageGroupMapping, messageGroup: UnformattedMessageGroup) => {
+ const groupId = messageGroup.group_id;
+ const displayTerm = messageGroup.display || messageGroup.phone_number || '???';
+ const isUser = messageGroup.participant_identifier == userIdentifier;
+ // Is already mapped?
+ if (groupId in mapping) {
+ // Add participant phone number
+ mapping[groupId].phoneNumbers = mapping[groupId].phoneNumbers.concat(
+ messageGroup.phone_number,
+ );
+ if (isUser) {
+ // Add unread count if its user's message group
+ mapping[groupId].unreadCount = messageGroup.unreadCount;
+ return mapping;
+ }
+ // Add participant if its not user's message group
+ mapping[groupId].participants = mapping[groupId].participants.concat(displayTerm);
+ return mapping;
+ }
+ if (isUser) {
+ // Group not mapped and its current user
+ mapping[groupId] = {
+ user_identifier: messageGroup.user_identifier,
+ unreadCount: messageGroup.unreadCount,
+ avatar: null,
+ label: null,
+ participants: [],
+ phoneNumbers: [messageGroup.phone_number],
+ updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
+ };
+ return mapping;
+ }
+ // Group not mapped and its not current user
+ mapping[groupId] = {
+ user_identifier: messageGroup.user_identifier,
+ unreadCount: 0,
+ avatar: messageGroup.avatar,
+ label: messageGroup.label,
+ participants: [displayTerm],
+ phoneNumbers: [messageGroup.phone_number],
+ updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
+ };
+ return mapping;
+ },
+ {},
+ );
+}
+
+export async function getGroupIds(
+ userIdentifier: string,
+ groupMapping: MessageGroupMapping,
+): Promise {
+ const groupIds: string[] = [];
+ for (const groupId of Object.keys(groupMapping)) {
+ const isMine = groupMapping[groupId].user_identifier == userIdentifier;
+ if (isMine || (await MessagesDB.getMessageCountByGroup(groupId)) > 0) {
+ groupIds.push(groupId);
+ }
+ }
+ return groupIds;
+}
+
+/**
+ * Given the mapping of groupId: fields contents reduce it into a list
+ * of MessageGroup objects ready for the UI to consume
+ * @param userIdentifier - user to generate the MessageGroups for
+ */
+export async function getFormattedMessageGroups(userIdentifier: string): Promise {
+ const groupMapping = await getConsolidatedMessageGroups(userIdentifier);
+ const groupIds = await getGroupIds(userIdentifier, groupMapping);
+
+ return groupIds.map((groupId) => {
+ const group = groupMapping[groupId];
+ return {
+ ...group,
+ groupId,
+ groupDisplay: group.participants.join(', '),
+ // note that the 1 here references how many participants besides the user
+ isGroupChat: group.participants.length > 1,
+ };
+ });
+}
+
+/**
+ * Create the same unique ID from an identifiers array.
+ * They will be always be sorted to ensure always the same ID.
+ * @param identifiers array of player identifiers
+ */
+export function createGroupHashID(identifiers: string[]) {
+ // make sure we are always in a consistent order. It is very important
+ // that this not change! Changing this order can result in the ability
+ // of duplicate message groups being created.
+ identifiers.sort();
+ const mergedIdentifiers = identifiers.join('+');
+ // we don't need this to be secure. Its purpose is to create a unique
+ // string derived from the identifiers. In this way we can check
+ // that this groupId isn't used before. If it has then it means
+ // we are trying to create a duplicate message group!
+ return mergedIdentifiers;
+}
+
+/**
+ * Main method to handle creation of new message groups. First
+ * we retrieve identifiers for each submitted phone number and
+ * then rows in npwd_messages_groups are created for each of them
+ * bound to a unique groupId. The groupId is any unique string - we
+ * use hashes here.
+ *
+ * These queries are batched with a transaction so that if any of
+ * them fail the queries are not committed to the database. This helps
+ * avoid situations where some participants get added to the group but
+ * one fails resulting in a partial group which would be very confusing
+ * to the player.
+ * @param userIdentifier - user who is creating the group
+ * @param phoneNumbers - list of phone numbers to add to the grup
+ * @param groupLabel - optional group label to give the group
+ */
+export async function createMessageGroupsFromPhoneNumbers(
+ userIdentifier: string,
+ phoneNumbers: string[],
+ groupLabel: string,
+): Promise {
+ // we check that each phoneNumber exists before we create the group
+ const identifiers: string[] = [];
+ const failedNumbers: string[] = [];
+
+ for (const phoneNumber of phoneNumbers) {
+ try {
+ const identifier = await MessagesDB.getIdentifierFromPhoneNumber(phoneNumber);
+ identifiers.push(identifier);
+ } catch (e) {
+ failedNumbers.push(phoneNumber);
+ }
+ }
+
+ if (phoneNumbers.length === failedNumbers.length) {
+ return { error: true, allNumbersFailed: true, failedNumbers };
+ }
+
+ // don't allow explicitly adding yourself
+ if (identifiers.some((identifier) => identifier == userIdentifier)) {
+ return { error: true, mine: true, failedNumbers };
+ }
+
+ const groupId = createGroupHashID([userIdentifier, ...identifiers]);
+ if (await MessagesDB.checkIfMessageGroupExists(groupId)) {
+ return { error: false, duplicate: true, groupId, identifiers, failedNumbers };
+ }
+
+ const queryPromises = [
+ // create a row that contains ourselves so reverse accessing from
+ // other players works as expected
+ MessagesDB.createMessageGroup(userIdentifier, groupId, userIdentifier),
+ ...identifiers.map((identifier) =>
+ MessagesDB.createMessageGroup(userIdentifier, groupId, identifier),
+ ),
+ ];
+
+ // we allow users to attach labels to name their group chats
+ if (groupLabel) {
+ queryPromises.push(MessagesDB.createLabel(userIdentifier, groupId, groupLabel));
+ }
+
+ // wrap this in a transaction to make sure ALL of these INSERTs succeed
+ // so we are not left in a situation where only some of the member of the
+ // group exist while other are left off.
+ await withTransaction(queryPromises);
+
+ return { error: false, groupId, identifiers, failedNumbers };
+}
+
+// getting the participants from groupId.
+// this should return the source or and array of identifiers
+export function getIdentifiersFromParticipants(groupId: string) {
+ return groupId.split('+');
+}
diff --git a/resources/server/notes/notes.controller.ts b/resources/server/notes/notes.controller.ts
new file mode 100644
index 0000000..b832c6e
--- /dev/null
+++ b/resources/server/notes/notes.controller.ts
@@ -0,0 +1,32 @@
+import { Note, NotesEvents } from '../../../typings/notes';
+import { getSource } from '../utils/miscUtils';
+import NotesService from './notes.service';
+import { notesLogger } from './notes.utils';
+
+onNet(NotesEvents.ADD_NOTE, (note: Note) => {
+ const src = getSource();
+ NotesService.handleAddNote(src, note).catch((e) =>
+ notesLogger.error(`Error occured in add note event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(NotesEvents.FETCH_ALL_NOTES, async (limit?: number) => {
+ const src = getSource();
+ NotesService.handleFetchNotes(src, limit).catch((e) =>
+ notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(NotesEvents.DELETE_NOTE, async (noteId: number) => {
+ const src = getSource();
+ NotesService.handleDeleteNote(src, noteId).catch((e) =>
+ notesLogger.error(`Error occured in delete note event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
+ const src = getSource();
+ NotesService.handleUpdateNote(src, note).catch((e) =>
+ notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/notes/notes.db.ts b/resources/server/notes/notes.db.ts
new file mode 100644
index 0000000..1e6a0a9
--- /dev/null
+++ b/resources/server/notes/notes.db.ts
@@ -0,0 +1,33 @@
+import { Note } from '../../../typings/notes';
+import { pool } from '../db';
+import { FetchDefaultLimits } from '../utils/ServerConstants';
+
+export class _NotesDB {
+ async addNote(identifier: string, note: Note): Promise {
+ const query = 'INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)';
+ await pool.query(query, [identifier, note.title, note.content]);
+ }
+
+ async fetchNotes(
+ identifier: string,
+ limit = FetchDefaultLimits.NOTES_FETCH_LIMIT,
+ ): Promise {
+ const query = 'SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC LIMIT ?';
+ const [result] = await pool.query(query, [identifier, limit]);
+ return result;
+ }
+
+ async deleteNote(noteId: number, identifier: string): Promise {
+ const query = 'DELETE FROM npwd_notes WHERE id = ? AND identifier = ?';
+ await pool.query(query, [noteId, identifier]);
+ }
+
+ async updateNote(note: Note, identifier: string): Promise {
+ const query = 'UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?';
+ await pool.query(query, [note.title, note.content, note.id, identifier]);
+ }
+}
+
+const NotesDB = new _NotesDB();
+
+export default NotesDB;
diff --git a/resources/server/notes/notes.service.ts b/resources/server/notes/notes.service.ts
new file mode 100644
index 0000000..8f84b46
--- /dev/null
+++ b/resources/server/notes/notes.service.ts
@@ -0,0 +1,94 @@
+import { Note, NotesEvents, NoteServerResponse } from '../../../typings/notes';
+import PlayerService from '../players/player.service';
+import NotesDB, { _NotesDB } from './notes.db';
+import { notesLogger } from './notes.utils';
+
+class _NotesService {
+ private readonly notesDB: _NotesDB;
+
+ constructor() {
+ this.notesDB = NotesDB;
+ notesLogger.debug('Notes service started');
+ }
+
+ async handleAddNote(src: number, note: Note): Promise {
+ notesLogger.debug('Handling add note, note:');
+ notesLogger.debug(note);
+
+ const identifer = PlayerService.getIdentifier(src);
+
+ try {
+ await this.notesDB.addNote(identifer, note);
+
+ emitNet(NotesEvents.SEND_NOTE_SUCCESS, src);
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_ADD_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ notesLogger.error(`Error in handleAddNote, ${e.message}`);
+
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_ADD_FAILED',
+ type: 'error',
+ });
+ }
+ }
+
+ async handleFetchNotes(src: number, limit?: number) {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ const notes = await this.notesDB.fetchNotes(identifier, limit);
+ emitNet(NotesEvents.SEND_NOTE, src, notes);
+ } catch (e) {
+ notesLogger.error(`Error in handleFetchNote, ${e.message}`);
+ }
+ }
+
+ async handleUpdateNote(src: number, note: Note) {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.notesDB.updateNote(note, identifier);
+ emitNet(NotesEvents.UPDATE_NOTE_SUCCESS, src);
+
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_UPDATE_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ emitNet(NotesEvents.UPDATE_NOTE_FAILURE, src);
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_UPDATE_FAILED',
+ type: 'error',
+ });
+ notesLogger.error(`Error in handleUpdateNote, ${e.message}`);
+ }
+ }
+
+ async handleShareNote(src: number) {
+ // To implement someday
+ }
+
+ async handleDeleteNote(src: number, noteId: number) {
+ const identifier = PlayerService.getIdentifier(src);
+ try {
+ await this.notesDB.deleteNote(noteId, identifier);
+
+ emitNet(NotesEvents.DELETE_NOTE_SUCCESS, src);
+
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_DELETE_SUCCESS',
+ type: 'success',
+ });
+ } catch (e) {
+ notesLogger.error(`Error in handleDeleteNote, ${e.message}`);
+ emitNet(NotesEvents.ACTION_RESULT, src, {
+ message: 'NOTES_DELETE_FAILED',
+ type: 'error',
+ });
+ }
+ }
+}
+
+const NotesService = new _NotesService();
+export default NotesService;
diff --git a/resources/server/notes/notes.utils.ts b/resources/server/notes/notes.utils.ts
new file mode 100644
index 0000000..db427b6
--- /dev/null
+++ b/resources/server/notes/notes.utils.ts
@@ -0,0 +1,3 @@
+import { mainLogger } from '../sv_logger';
+
+export const notesLogger = mainLogger.child({ module: 'notes' });
diff --git a/resources/server/photo/photo.controller.ts b/resources/server/photo/photo.controller.ts
new file mode 100644
index 0000000..984034d
--- /dev/null
+++ b/resources/server/photo/photo.controller.ts
@@ -0,0 +1,25 @@
+import { getSource } from '../utils/miscUtils';
+import { GalleryPhoto, PhotoEvents } from '../../../typings/photo';
+import PhotoService from './photo.service';
+import { photoLogger } from './photo.utils';
+
+onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
+ const src = getSource();
+ PhotoService.handleUploadPhoto(src, image).catch((e) =>
+ photoLogger.error(`Error occurred in upload photo event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(PhotoEvents.FETCH_PHOTOS, async () => {
+ const src = getSource();
+ PhotoService.handleFetchPhotos(src).catch((e) =>
+ photoLogger.error(`Error occurred in upload photo event (${src}), Error: ${e.message}`),
+ );
+});
+
+onNet(PhotoEvents.DELETE_PHOTO, async (photo: GalleryPhoto) => {
+ const src = getSource();
+ PhotoService.handleDeletePhoto(src, photo).catch((e) =>
+ photoLogger.error(`Error occurred in delete photo event (${src}), Error: ${e.message}`),
+ );
+});
diff --git a/resources/server/photo/photo.db.ts b/resources/server/photo/photo.db.ts
new file mode 100644
index 0000000..95b19b0
--- /dev/null
+++ b/resources/server/photo/photo.db.ts
@@ -0,0 +1,25 @@
+import { GalleryPhoto } from '../../../typings/photo';
+import { pool } from '../db';
+
+export class _PhotoDB {
+ async uploadPhoto(identifier: string, image: string): Promise {
+ const query = 'INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)';
+ const [results] = (await pool.query(query, [identifier, image])) as any;
+ return { id: results.insertId, image };
+ }
+
+ async getPhotosByIdentifier(identifier: string): Promise {
+ const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
+ const [results] = await pool.query(query, [identifier]);
+ return results;
+ }
+
+ async deletePhoto(photo: GalleryPhoto, identifier: string) {
+ const query = 'DELETE FROM npwd_phone_gallery WHERE image = ? AND identifier = ?';
+ await pool.query(query, [photo.image, identifier]);
+ }
+}
+
+const PhotoDB = new _PhotoDB();
+
+export default PhotoDB;
diff --git a/resources/server/photo/photo.service.ts b/resources/server/photo/photo.service.ts
new file mode 100644
index 0000000..cf913b5
--- /dev/null
+++ b/resources/server/photo/photo.service.ts
@@ -0,0 +1,53 @@
+import PlayerService from '../players/player.service';
+import { GalleryPhoto, PhotoEvents } from '../../../typings/photo';
+import PhotoDB, { _PhotoDB } from './photo.db';
+import { photoLogger } from './photo.utils';
+
+class _PhotoService {
+ private readonly photoDB: _PhotoDB;
+
+ constructor() {
+ this.photoDB = PhotoDB;
+ photoLogger.debug('Photo service started');
+ }
+
+ async handleUploadPhoto(src: number, image: string) {
+ try {
+ const identifier = PlayerService.getIdentifier(src);
+ const photo = await this.photoDB.uploadPhoto(identifier, image);
+ emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, src, photo);
+ } catch (e) {
+ photoLogger.error(`Failed to upload photo, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+
+ async handleFetchPhotos(src: number) {
+ try {
+ const identifier = PlayerService.getIdentifier(src);
+ const photos = await this.photoDB.getPhotosByIdentifier(identifier);
+ emitNet(PhotoEvents.SEND_PHOTOS, src, photos);
+ } catch (e) {
+ photoLogger.error(`Failed to fetch photos, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+
+ async handleDeletePhoto(src: number, photo: GalleryPhoto) {
+ try {
+ const identifier = PlayerService.getIdentifier(src);
+ await this.photoDB.deletePhoto(photo, identifier);
+ emitNet(PhotoEvents.DELETE_PHOTO_SUCCESS, src);
+ } catch (e) {
+ photoLogger.error(`Failed to fetch photos, ${e.message}`, {
+ source: src,
+ });
+ }
+ }
+}
+
+const PhotoService = new _PhotoService();
+
+export default PhotoService;
diff --git a/resources/server/photo/photo.utils.ts b/resources/server/photo/photo.utils.ts
new file mode 100644
index 0000000..e0f5584
--- /dev/null
+++ b/resources/server/photo/photo.utils.ts
@@ -0,0 +1,3 @@
+import { mainLogger } from '../sv_logger';
+
+export const photoLogger = mainLogger.child({ module: 'photo' });
diff --git a/resources/server/players/player.class.ts b/resources/server/players/player.class.ts
new file mode 100644
index 0000000..6f839f2
--- /dev/null
+++ b/resources/server/players/player.class.ts
@@ -0,0 +1,86 @@
+import { CreatePlayerInstance } from './player.interfaces';
+
+export class Player {
+ public readonly source: number;
+ public readonly username: string;
+ private _phoneNumber: string;
+ private _identifier: string;
+ private _firstname: string | null;
+ private _lastname: string | null;
+
+ constructor({ source, identifier, phoneNumber, username }: CreatePlayerInstance) {
+ this.source = source;
+ this._identifier = identifier;
+ this._phoneNumber = phoneNumber;
+ this.username = username;
+ }
+
+ public getIdentifier(): string {
+ return this._identifier;
+ }
+
+ /**
+ * Set the identifier for a player, useful in systems with multicharacter
+ * players
+ * @param identifier {string} - Set the identifier for a player
+ */
+ public setIdentifier(identifier: string): Player {
+ this._identifier = identifier;
+ return this;
+ }
+
+ /**
+ * Returns the stored firstname for a user
+ */
+ public getFirstName(): string | null {
+ return this._firstname;
+ }
+
+ /**
+ * Set the first name for a user
+ * @param firstname {string} The first name to set for the user
+ **/
+ public setFirstName(firstname: string): Player {
+ this._firstname = firstname;
+ return this;
+ }
+
+ /**
+ * Returns the stored lastname for a user
+ **/
+ public getLastName(): string | null {
+ return this._lastname;
+ }
+
+ /**
+ * Set the last name for a user
+ * @param lastname {string} The last name to set for the user
+ **/
+ public setLastName(lastname: string): Player {
+ this._lastname = lastname;
+ return this;
+ }
+
+ /**
+ * Get the full name of the user
+ **/
+ public getName(): string | null {
+ if (!this._firstname || !this._lastname) return null;
+ return `${this._firstname} ${this._lastname}`;
+ }
+
+ /**
+ * Get the stored phone number for a user
+ **/
+ public getPhoneNumber(): string {
+ return this._phoneNumber;
+ }
+
+ /**
+ * Set the stored phone number for a user
+ **/
+ public setPhoneNumber(number: string): Player {
+ this._phoneNumber = number;
+ return this;
+ }
+}
diff --git a/resources/server/players/player.controller.ts b/resources/server/players/player.controller.ts
new file mode 100644
index 0000000..42b654c
--- /dev/null
+++ b/resources/server/players/player.controller.ts
@@ -0,0 +1,76 @@
+import { getSource } from '../utils/miscUtils';
+import PlayerService from './player.service';
+import { config } from '../server';
+import { PlayerAddData } from './player.interfaces';
+import { playerLogger } from './player.utils';
+
+/**
+ * Essentially this whole file acts as a controller layer
+ * for player related actions. Everything here is registered,
+ * within the global scope like routes in a web server.
+ */
+
+// If multicharacter mode is disabled, we instantiate a new
+// NPWD player by ourselves without waiting for an export
+
+if (!config.general.enableMultiChar) {
+ on('playerJoining', async () => {
+ const src = getSource();
+ await PlayerService.handleNewPlayerJoined(src);
+ });
+}
+
+// Handle removing from player maps when player disconnects
+on('playerDropped', () => {
+ const src = getSource();
+ // Get identifier for player to remove
+ PlayerService.handleUnloadPlayerEvent(src, true);
+});
+
+// Can use this to debug the player table if needed. Disabled by default
+// RegisterCommand(
+// 'getPlayers',
+// () => {
+// playerLogger.debug(Players);
+// },
+// false,
+// );
+
+// Used for debug purposes, if the resource is restarted and the multicharacter option is false
+// we will handle all the currently online players
+if (!config.general.enableMultiChar) {
+ on('onServerResourceStart', async (resource: string) => {
+ if (resource === GetCurrentResourceName()) {
+ // Workaround till https://github.com/citizenfx/fivem/pull/682
+ // is merged
+ // @ts-ignore
+ const onlinePlayers: string[] = getPlayers();
+ for (const player of onlinePlayers) {
+ await PlayerService.handleNewPlayerJoined(parseInt(player));
+ }
+ }
+ });
+}
+
+// For multicharacter frameworks, we enable these events for
+// instantiating/deleting a player. The config option must be set to true
+// for these to be available
+if (config.general.enableMultiChar) {
+ // This has to be an event as FXServer does not yet support exports which return a promise.
+ on('npwd:newPlayer', async (playerDTO: PlayerAddData) => {
+ if (typeof playerDTO.source !== 'number') {
+ return playerLogger.error('Source must be passed as a number when unloading a player');
+ }
+ playerLogger.debug('Receive newPlayer event, data:');
+ playerLogger.debug(playerDTO);
+ await PlayerService.handleNewPlayerEvent(playerDTO);
+ });
+
+ on('npwd:unloadPlayer', (src: number) => {
+ if (typeof src !== 'number') {
+ return playerLogger.error('Source must be passed as a number when unloading a player');
+ }
+ playerLogger.debug(`Received unloadPlayer event for ${src}`);
+ PlayerService.handleUnloadPlayerEvent(src);
+ });
+}
diff --git a/resources/server/players/player.db.ts b/resources/server/players/player.db.ts
new file mode 100644
index 0000000..5896c43
--- /dev/null
+++ b/resources/server/players/player.db.ts
@@ -0,0 +1,13 @@
+import { config } from '../server';
+import { pool } from '../db';
+
+export class PlayerRepo {
+ async fetchIdentifierFromPhoneNumber(phoneNumber: string): Promise {
+ const query = `SELECT ${config.database.identifierColumn} FROM ${config.database.playerTable} WHERE phone_number = ?`;
+ const [results] = await pool.query(query, [phoneNumber]);
+ // Get identifier from results
+ return (results as { identifier: string }[])[0].identifier || null;
+ }
+}
+
+export default new PlayerRepo();
diff --git a/resources/server/players/player.interfaces.ts b/resources/server/players/player.interfaces.ts
new file mode 100644
index 0000000..b4a3a1b
--- /dev/null
+++ b/resources/server/players/player.interfaces.ts
@@ -0,0 +1,13 @@
+export interface PlayerAddData {
+ source: number;
+ identifier: string;
+ firstname?: string;
+ lastname?: string;
+}
+
+export interface CreatePlayerInstance {
+ source: number;
+ username: string;
+ identifier: string;
+ phoneNumber: string;
+}
diff --git a/resources/server/players/player.service.ts b/resources/server/players/player.service.ts
new file mode 100644
index 0000000..6e7ae72
--- /dev/null
+++ b/resources/server/players/player.service.ts
@@ -0,0 +1,223 @@
+import { generatePhoneNumber } from '../functions';
+import { PhoneEvents } from '../../../typings/phone';
+import { Player } from './player.class';
+import { PlayerAddData } from './player.interfaces';
+import Collection from '@discordjs/collection';
+import { getPlayerGameLicense } from '../utils/getPlayerGameLicense';
+import playerDB, { PlayerRepo } from './player.db';
+import { playerLogger } from './player.utils';
+
+class _PlayerService {
+ private readonly playersBySource: Collection;
+ private readonly playersByIdentifier: Collection;
+ private readonly playerDB: PlayerRepo;
+
+ constructor() {
+ this.playersBySource = new Collection();
+ this.playersByIdentifier = new Collection();
+ this.playerDB = playerDB;
+ playerLogger.debug('Player Service started');
+ }
+
+ /**
+ * Adds a Player instance to the source & identifier maps
+ * @param source - The player's source
+ * @param player - The player instance to use as a value
+ */
+
+ addPlayerToMaps(source: number, player: Player) {
+ this.playersBySource.set(source, player);
+ this.playersByIdentifier.set(player.getIdentifier(), player);
+ }
+
+ /**
+ * Deletes a player from both map by source & identifier
+ * @param source - The player's source
+ */
+ deletePlayerFromMaps(source: number) {
+ const identifier = this.playersBySource.get(source).getIdentifier();
+ this.playersByIdentifier.delete(identifier);
+ this.playersBySource.delete(source);
+ }
+ /**
+ * Returns the player instance for a given source
+ * Will return null if no player is found online with that source
+ **/
+ getPlayer(source: number): Player | null {
+ const player = this.playersBySource.get(source);
+ if (!player) return null;
+ return player;
+ }
+
+ /**
+ * Returns the player identifier for a given source
+ * Will return null if no player is found online with that source
+ **/
+ getIdentifier(source: number): string {
+ return this.getPlayer(source).getIdentifier();
+ }
+
+ /**
+ * Returns the player phoneNumber for a passed identifier
+ * @param identifier The players phone number
+ */
+ getPlayerFromIdentifier(identifier: string): Player | null {
+ const player = this.playersByIdentifier.get(identifier);
+ if (!player)
+ throw new Error(`Could not find corresponding player for identifier: ${identifier}`);
+ return player;
+ }
+
+ /**
+ * Will return the given identifier from a phone number
+ * @param phoneNumber - The phone number of the player
+ * @param fetch - Whether to fetch for the identifier if they are offline
+ **/
+ async getIdentifierFromPhoneNumber(phoneNumber: string, fetch?: boolean): Promise {
+ const onlinePlayer = this.playersBySource.find(
+ (player: Player) => player.getPhoneNumber() === phoneNumber,
+ );
+ // Return the player if they are online
+ if (onlinePlayer) return onlinePlayer.getIdentifier();
+ if (fetch) {
+ const fetchResult: string | null = await this.playerDB
+ .fetchIdentifierFromPhoneNumber(phoneNumber)
+ .catch((e) => {
+ playerLogger.error(
+ `Failed to fetch identifier from phone number for ${phoneNumber}, error: ${e.message}`,
+ );
+ return null;
+ });
+
+ return fetchResult;
+ }
+ // Return null if all else doesn't return
+ return null;
+ }
+
+ /**
+ * We call this function on the event `playerJoined`,
+ * only if the multicharacter option is set to false in the config.
+ * @param pSource - The source of the player to handle
+ */
+ async handleNewPlayerJoined(pSource: number) {
+ const playerIdentifier = getPlayerGameLicense(pSource);
+
+ if (!playerIdentifier) {
+ throw new Error(`License identifier could not be found for source (${pSource})`);
+ }
+
+ const username = GetPlayerName(pSource.toString());
+ playerLogger.info(`Started loading for ${username} (${pSource})`);
+ // Ensure phone number exists or generate
+
+ let phone_number: string;
+ try {
+ phone_number = await generatePhoneNumber(playerIdentifier);
+ } catch (e) {
+ return;
+ }
+
+ const newPlayer = new Player({
+ identifier: playerIdentifier,
+ source: pSource,
+ username,
+ phoneNumber: phone_number,
+ });
+
+ this.addPlayerToMaps(pSource, newPlayer);
+
+ playerLogger.info('NPWD Player Loaded!');
+ playerLogger.debug(newPlayer);
+
+ // Emit to client that player is ready
+ emitNet(PhoneEvents.PLAYER_IS_READY, pSource, true);
+ }
+
+ /**
+ * Instantiate a basic Player instance from the constructor
+ * @param src - The player source
+ * @param identifier - The primary identifier
+ *
+ */
+
+ async createNewPlayer({
+ src,
+ identifier,
+ }: {
+ src: number;
+ identifier: string;
+ }): Promise {
+ const username = GetPlayerName(src.toString());
+
+ const phoneNumber = await generatePhoneNumber(identifier).catch((e) => {
+ playerLogger.error(`Failed to generate phone number for source: ${src}. Error: ${e.message}`);
+ return null;
+ });
+
+ if (!phoneNumber) return null;
+
+ return new Player({
+ source: src,
+ identifier,
+ phoneNumber,
+ username,
+ });
+ }
+
+ /**
+ * We call this function whenever we receive a `npwd:newPlayer`
+ * event while multichar is enabled.
+ * @param NewPlayerDTO - A DTO with all the new info required to instantiate a new player
+ *
+ */
+ async handleNewPlayerEvent({ source: src, identifier, firstname, lastname }: PlayerAddData) {
+ const player = await this.createNewPlayer({ src, identifier });
+
+ if (firstname) player.setFirstName(firstname);
+ if (lastname) player.setLastName(lastname);
+
+ this.addPlayerToMaps(src, player);
+
+ playerLogger.info(`New NPWD Player added through event (${src}) (${identifier})`);
+ playerLogger.debug(player);
+
+ // Emit to client that player is ready
+ emitNet(PhoneEvents.PLAYER_IS_READY, src, true);
+ }
+
+ /**
+ * Return the attached identifier for a given phone number
+ * @param phoneNumber The phone number to return identifier for
+ * @param fetch Whether or not to query the database if a given player is offline
+ **/
+ async getIdentifierByPhoneNumber(phoneNumber: string, fetch?: boolean): Promise {
+ for (const [source, player] of this.playersBySource) {
+ if (player.getPhoneNumber() === phoneNumber) return player.getIdentifier();
+ }
+ // Whether we fetch from database if not found in online players
+ if (fetch) {
+ return await this.playerDB.fetchIdentifierFromPhoneNumber(phoneNumber);
+ }
+ }
+
+ /**
+ * Unload event handler
+ * @param src - Source of player being unloaded
+ * @param playerDropped - Whether the player disconnected or is being unloaded for multichar
+ **/
+ handleUnloadPlayerEvent(src: number, playerDropped?: boolean) {
+ this.deletePlayerFromMaps(src);
+
+ playerLogger.info(`Unloaded NPWD Player, source: (${src})`);
+
+ // We emit PLAYER_IS_READY false if the player wasn't disconnected
+ if (!playerDropped) {
+ emitNet(PhoneEvents.PLAYER_IS_READY, src, false);
+ }
+ }
+}
+
+const PlayerService = new _PlayerService();
+
+export default PlayerService;
diff --git a/resources/server/players/player.utils.ts b/resources/server/players/player.utils.ts
new file mode 100644
index 0000000..f7e4a67
--- /dev/null
+++ b/resources/server/players/player.utils.ts
@@ -0,0 +1,5 @@
+import { mainLogger } from '../sv_logger';
+
+export const playerLogger = mainLogger.child({
+ module: 'player',
+});
diff --git a/resources/server/players/sv_player_events.ts b/resources/server/players/sv_player_events.ts
deleted file mode 100644
index 2b8984a..0000000
--- a/resources/server/players/sv_player_events.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { getPlayer, getSource } from '../functions';
-import { mainLogger } from '../sv_logger';
-import { handlePlayerAdd, Players, PlayersByIdentifier } from './sv_players';
-
-on('playerJoining', async () => {
- const _source = getSource();
- await handlePlayerAdd(_source);
-});
-
-// Handle removing from player maps when player disconnects
-on('playerDropped', () => {
- const _source = getSource();
- // Get identifier for player to remove
- const playerIdentifier = getPlayer(_source).identifier;
- // Remove from player map by identifier
- PlayersByIdentifier.delete(playerIdentifier);
- // Remove from player map by source
- Players.delete(_source);
-
- mainLogger.info(`Unloaded NPWD Player, source: (${_source})`);
-});
-
-// Can use this to debug the player table if needed. Disabled by default
-// RegisterCommand(
-// 'getPlayers',
-// () => {
-// playerLogger.debug(Players);
-// },
-// false,
-// );
-
-on('onServerResourceStart', async (resource: string) => {
- if (resource === GetCurrentResourceName()) {
- // Workaround till https://github.com/citizenfx/fivem/pull/682
- // is merged
- // @ts-ignore
- const onlinePlayers: string[] = getPlayers();
- for (const player of onlinePlayers) {
- await handlePlayerAdd(parseInt(player));
- }
- }
-});
diff --git a/resources/server/players/sv_players.ts b/resources/server/players/sv_players.ts
deleted file mode 100644
index cf3875c..0000000
--- a/resources/server/players/sv_players.ts
+++ /dev/null
@@ -1,235 +0,0 @@
-import { mainLogger } from '../sv_logger';
-import { pool } from '../db';
-import { generatePhoneNumber } from '../functions';
-import { PhoneEvents } from '../../../typings/phone';
-
-export const playerLogger = mainLogger.child({
- module: 'player',
-});
-
-// Map of players by source
-export const Players = new Map();
-// Map of players by identifier
-export const PlayersByIdentifier = new Map();
-
-export async function handlePlayerAdd(pSource: number) {
- const playerIdentifiers = getPlayerIdentifiers(pSource.toString());
-
- // Parse specifically for license identifier as its
- // guranteed
- let playerIdentifer;
- for (const identifier of playerIdentifiers) {
- if (identifier.includes('license:')) {
- playerIdentifer = identifier.split(':')[1];
- }
- }
-
- if (!playerIdentifer) {
- throw new Error('License identifier could not be found.');
- }
-
- try {
- const username = GetPlayerName(pSource.toString());
- playerLogger.info(`Started loading for ${username} (${pSource})`);
- // Ensure phone number exists or generate
- const phone_number = await generatePhoneNumber(playerIdentifer);
-
- // Get player info to populate class instance
- let playerInfo = { firstname: '', lastname: '' };
- try {
- playerInfo = await getPlayerInfo(playerIdentifer);
- } catch (e) {
- playerLogger.debug(
- `Failed to get player info, defaulting to phone number as profile, ${e.message}`,
- {
- source: pSource,
- },
- );
- }
- const { firstname, lastname } = playerInfo;
-
- const newPlayer = new Player({
- identifier: playerIdentifer,
- source: pSource,
- username,
- firstname,
- lastname,
- phoneNumber: phone_number,
- });
-
- // Add to players by identifier map
- PlayersByIdentifier.set(newPlayer.identifier, newPlayer);
-
- // Add to players by source map
- Players.set(pSource, newPlayer);
-
- playerLogger.info('NPWD Player Loaded!');
- playerLogger.debug(newPlayer);
-
- // Emit to client that player is ready
- emitNet(PhoneEvents.PLAYER_IS_READY, pSource);
- } catch (e) {
- playerLogger.error(`Failed to create a new player, ${e.message}`, {
- source: pSource,
- });
- }
-}
-
-interface PlayerQueryResp {
- firstname: string;
- lastname: string;
- phone_number: string;
-}
-
-// Get initial player data to populate new class instance
-// NOTE: We should make this more generic and as easily configurable as possible
-export async function getPlayerInfo(identifier: string): Promise {
- const query = `SELECT firstname, lastname, phone_number
- FROM users
- WHERE identifier = ?`;
-
- const [results] = await pool.query(query, [identifier]);
-
- const creds = results;
- if (!creds[0]) throw new Error(`Could not get player information for ${identifier}`);
-
- const firstname = creds[0].firstname;
- const lastname = creds[0].lastname;
-
- const phone_number = creds[0].phone_number;
- return { firstname, lastname, phone_number };
-}
-
-const clean = (input: string) => (input ? input.replace(/[^0-9a-z]/gi, '') : input);
-
-async function getCleanedPlayerInfo(identifier: string): Promise {
- const { firstname, lastname, phone_number } = await getPlayerInfo(identifier);
- return {
- firstname: clean(firstname),
- lastname: clean(lastname),
- phone_number: clean(phone_number),
- };
-}
-
-/**
- * Generate a profile name by the player's name and/or phone number
- * @param identifier - player's identifier
- */
-export async function generateProfileName(
- identifier: string,
- delimiter: string = '_',
-): Promise {
- const { firstname, lastname, phone_number } = await getCleanedPlayerInfo(identifier);
-
- if (firstname && lastname) {
- return `${firstname}${delimiter}${lastname}`;
- } else if (firstname) {
- return firstname;
- } else if (lastname) {
- return lastname;
- } else if (phone_number) {
- return phone_number;
- }
- return null;
-}
-
-export async function getDefaultProfileNames(identifier: string): Promise {
- const { firstname, lastname, phone_number } = await getCleanedPlayerInfo(identifier);
- let defaultProfileNames = [];
-
- if (firstname && lastname) {
- defaultProfileNames.push(`${firstname}_${lastname}`);
- } else if (firstname) {
- defaultProfileNames.push(firstname);
- } else if (lastname) {
- defaultProfileNames.push(lastname);
- }
-
- if (phone_number) {
- defaultProfileNames.push(phone_number);
- }
- return defaultProfileNames;
-}
-
-// Attach to playerJoining event as this is when
-// the permanent source is assigned for the user
-
-interface PlayerClassArgs {
- source: number;
- username: string;
- firstname: string;
- lastname: string;
- identifier: string;
- phoneNumber: string;
-}
-
-// Public getters/setters are for servers with multicharacter systems
-// who need to switch certain information when character is changed
-
-export class Player {
- public readonly source: number;
- public readonly identifier: string;
- public readonly username: string;
- private _firstname: string;
- private _lastname: string;
- private _phoneNumber: string;
-
- constructor({ source, firstname, lastname, identifier, phoneNumber, username }: PlayerClassArgs) {
- this.source = source;
- this.identifier = identifier;
- this._firstname = firstname;
- this._lastname = lastname;
- this._phoneNumber = phoneNumber;
- this.username = username;
- }
- /**
- * Returns the stored firstname for a user
- **/
- public getFirstName(): string {
- return this._firstname;
- }
-
- /**
- * Set the first name for a user
- * @param firstname {string} The first name to set for the user
- **/
- public setFirstName(firstname: string): void {
- this._firstname = firstname;
- }
-
- /**
- * Returns the stored lastname for a user
- **/
- public getLastName(): string {
- return this._lastname;
- }
-
- /**
- * Set the last name for a user
- * @param lastname {string} The last name to set for the user
- **/
- public setLastName(lastname: string): void {
- this._lastname = lastname;
- }
-
- /**
- * Get the full name of the user
- **/
- public getName(): string {
- return `${this._firstname} ${this._lastname}`;
- }
-
- /**
- * Get the stored phone number for a user
- **/
- public getPhoneNumber(): string {
- return this._phoneNumber;
- }
-
- /**
- * Set the stored phone number for a user
- **/
- public setPhoneNumber(number: string): void {
- this._phoneNumber = number;
- }
-}
diff --git a/resources/server/server.ts b/resources/server/server.ts
index 9029292..7f81c09 100644
--- a/resources/server/server.ts
+++ b/resources/server/server.ts
@@ -6,18 +6,20 @@ export const config: ResourceConfig = JSON.parse(
LoadResourceFile(GetCurrentResourceName(), 'config.json'),
);
+// Setup controllers
import './db';
+import './players/player.controller';
+import './calls/calls.controller';
+import './notes/notes.controller';
+import './contacts/contacts.controller';
+import './photo/photo.controller';
+import './messages/messages.controller';
+import './marketplace/marketplace.controller';
+
import './sv_twitter';
import './sv_main';
-import './sv_contacts';
-import './sv_marketplace';
import './sv_bank';
-import './sv_notes';
-import './sv_photo';
-import './sv_messages';
import './sv_match';
-import './sv_call';
-import './players/sv_player_events';
import { mainLogger } from './sv_logger';
export let ESX: Server = null;
diff --git a/resources/server/sv_bank.ts b/resources/server/sv_bank.ts
index f8f1e92..2a6e8c2 100644
--- a/resources/server/sv_bank.ts
+++ b/resources/server/sv_bank.ts
@@ -1,9 +1,9 @@
import { ESX } from './server';
-import { getSource } from './functions';
import { pool } from './db';
import { Transfer, IBankCredentials, BankEvents } from '../../typings/bank';
-import { getIdentifier } from './functions';
import { mainLogger } from './sv_logger';
+import { getSource } from './utils/miscUtils';
+import PlayerService from './players/player.service';
const bankLogger = mainLogger.child({ module: 'bank' });
@@ -77,7 +77,7 @@ async function getTransfer(transferId: number): Promise {
onNet(BankEvents.FETCH_TRANSACTIONS, async () => {
const _source = getSource();
try {
- const _identifier = getIdentifier(_source);
+ const _identifier = PlayerService.getIdentifier(_source);
const transfer = await fetchAllTransactions(_identifier);
emitNet(BankEvents.SEND_TRANSFERS, _source, transfer);
@@ -92,7 +92,7 @@ onNet(BankEvents.ADD_TRANSFER, async (transfer: Transfer) => {
const _source = getSource();
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
try {
- const _identifier = getIdentifier(_source);
+ const _identifier = PlayerService.getIdentifier(_source);
await addTransfer(_identifier, transfer);
// we need to create a notification for bank. that's why i have commented out.
diff --git a/resources/server/sv_call.ts b/resources/server/sv_call.ts
deleted file mode 100644
index e9f6bc0..0000000
--- a/resources/server/sv_call.ts
+++ /dev/null
@@ -1,169 +0,0 @@
-import { CallEvents } from '../../typings/call';
-import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
-import { getPlayerFromIdentifier } from './functions';
-import { CallHistoryItem } from '../../typings/call';
-
-import { pool } from './db';
-import { v4 as uuidv4 } from 'uuid';
-import { mainLogger } from './sv_logger';
-
-const callLogger = mainLogger.child({ module: 'calls' });
-
-async function saveCall(call: CallHistoryItem) {
- const query =
- 'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
- await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
-}
-
-async function updateCall(call: CallHistoryItem, isAccepted: boolean, end: number) {
- const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
- await pool.query(query, [isAccepted, end, call.identifier]);
-}
-
-async function fetchCalls(phoneNumber: string): Promise {
- const query = 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC';
- const [result] = await pool.query(query, [phoneNumber, phoneNumber]);
- const calls = result;
- return calls;
-}
-
-let calls: Map = new Map();
-
-onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
- const _source = getSource();
-
- const startCallTimeUnix = new Date().getTime() / 1000;
-
- const callIdentifier = uuidv4();
-
- // the client that is calling
- // TODO: Handle offline player calling
- const transmitterNumber = getPlayer(_source).getPhoneNumber();
-
- // player who is being called
- const receiverIdentifier = await getIdentifierByPhoneNumber(phoneNumber, true);
- const xReceiver = getPlayerFromIdentifier(receiverIdentifier);
- const receiverNumber = phoneNumber;
-
- if (!xReceiver.source) {
- callLogger.error('Player you are trying to call is not online', {
- source: _source,
- });
- }
-
- callLogger.debug('Receiver Number:', receiverIdentifier);
-
- callLogger.debug(`${_source} xReceiver.source`);
-
- calls.set(transmitterNumber, {
- identifier: callIdentifier,
- transmitter: transmitterNumber,
- transmitterSource: _source,
- receiver: receiverNumber,
- receiverSource: xReceiver.source,
- start: Math.floor(startCallTimeUnix),
- accepted: false,
- });
-
- callLogger.debug(`Call Set key: ${transmitterNumber}`);
-
- const currentCall = calls.get(transmitterNumber);
- await saveCall(currentCall);
-
- // events
- // client that is calling
- emitNet(CallEvents.START_CALL, _source, transmitterNumber, receiverNumber, true);
-
- // client that is being called
- emitNet(CallEvents.START_CALL, xReceiver.source, transmitterNumber, receiverNumber, false);
-});
-
-onNet(CallEvents.ACCEPT_CALL, async (transmitterNumber: string) => {
- const pSource = getSource();
- try {
- const currentCall = calls.get(transmitterNumber);
-
- // Sanity check if call exists in current set
- if (!currentCall) new Error('Transmitter number does not exist in set.');
-
- const channelId = pSource;
-
- await updateCall(currentCall, true, null);
-
- // player who is being called
- emitNet(CallEvents.WAS_ACCEPTED, pSource, channelId, currentCall, false);
-
- // player who is calling
- emitNet(CallEvents.WAS_ACCEPTED, currentCall.transmitterSource, channelId, currentCall, true);
-
- currentCall.accepted = true;
- } catch (e) {
- callLogger.error('Accepting Call Error', e.message, {
- source: pSource,
- });
- }
-});
-
-onNet(CallEvents.REJECTED, async (transmitterNumber: string, timestamp: number) => {
- const pSource = getSource();
- try {
- const currentCall = calls.get(transmitterNumber);
-
- // Sanity check if call exists in current set
- if (!currentCall) new Error('Transmitter number does not exist in set.');
- await updateCall(currentCall, false, timestamp);
-
- // player who is called and initiasted the rejection.
- emitNet(CallEvents.WAS_REJECTED, currentCall.receiverSource);
-
- // player who is calling and recieved the rejection.
- emitNet(CallEvents.WAS_REJECTED, currentCall.transmitterSource);
- calls.delete(transmitterNumber);
- } catch (e) {
- callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
- source: pSource,
- });
- }
-});
-
-onNet(CallEvents.END_CALL, async (transmitterNumber: string) => {
- const pSource = getSource();
- try {
- const currentTimeUnix = new Date().getTime() / 1000;
-
- const currentCall = calls.get(transmitterNumber);
-
- // Sanity check if call exists in current set
- if (!currentCall) new Error('Transmitter number does not exist in set.');
-
- await updateCall(currentCall, false, currentTimeUnix);
-
- // player who is being called
- emitNet(CallEvents.WAS_ENDED, currentCall.receiverSource);
- // player who is calling
- emitNet(CallEvents.WAS_ENDED, currentCall.transmitterSource);
- // ends animations if call is active
- if (currentCall.accepted) {
- emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.receiverSource);
- emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.transmitterSource);
- }
- calls.delete(transmitterNumber);
- } catch (e) {
- callLogger.error(`Error ending Phone Call, ${e.message}`, {
- source: pSource,
- });
- }
-});
-
-onNet(CallEvents.FETCH_CALLS, async () => {
- const _source = getSource();
- try {
- const phoneNumber = getPlayer(_source).getPhoneNumber();
- const calls = await fetchCalls(phoneNumber);
- emitNet(CallEvents.SEND_HISTORY, _source, calls);
- } catch (e) {
- callLogger.error(`Failed to fetch calls, ${e.message}`, {
- source: _source,
- });
- }
-});
diff --git a/resources/server/sv_contacts.ts b/resources/server/sv_contacts.ts
deleted file mode 100644
index dbb0203..0000000
--- a/resources/server/sv_contacts.ts
+++ /dev/null
@@ -1,131 +0,0 @@
-import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
-import { mainLogger } from './sv_logger';
-import { ContactEvents } from '../../typings/contact';
-
-const contactsLogger = mainLogger.child({ module: 'contact' });
-
-interface Contacts {
- id?: number;
- display: string;
- number: string;
- avatar: string;
-}
-
-interface ContactId {
- id: number;
-}
-
-async function fetchAllContacts(identifier: string): Promise {
- const query = 'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
- const [results] = await pool.query(query, [identifier]);
- const contacts = results;
- return contacts;
-}
-
-async function addContact(
- identifier: string,
- number: string,
- display: string,
- avatar: string,
-): Promise {
- const query =
- 'INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)';
-
- const [result] = await pool.query(query, [identifier, number, display, avatar]);
-}
-
-async function updateContact(contact: Contacts, identifier: string): Promise {
- const query =
- 'UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?';
- await pool.query(query, [
- contact.number,
- contact.display,
- contact.avatar,
- contact.id,
- identifier,
- ]);
-}
-
-async function deleteContact(contact: ContactId, identifier: string): Promise {
- const query = 'DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?';
- await pool.query(query, [contact.id, identifier]);
-}
-
-onNet(ContactEvents.GET_CONTACTS, async () => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
-
- const contacts = await fetchAllContacts(_identifier);
- emitNet(ContactEvents.SEND_CONTACTS, _source, contacts);
- } catch (e) {
- contactsLogger.error(`Failed to fetch contacts, ${e.message}`);
- }
-});
-
-onNet(ContactEvents.ADD_CONTACT, async (number: string, display: string, avatar: string) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- await addContact(_identifier, number, display, avatar);
- emitNet(ContactEvents.ADD_CONTACT_SUCCESS, _source);
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_ADD_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_ADD_FAILED',
- type: 'error',
- });
- contactsLogger.error(`Failed to add contact, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(ContactEvents.UPDATE_CONTACT, async (contact: Contacts) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- await updateContact(contact, _identifier);
-
- emitNet(ContactEvents.UPDATE_CONTACT_SUCCESS, _source);
-
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_UPDATE_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- const _source = (global as any).source;
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_UPDATE_FAILED',
- type: 'error',
- });
- contactsLogger.error(`Failed to update contact, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(ContactEvents.DELETE_CONTACT, async (contact: ContactId) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- await deleteContact(contact, _identifier);
- emitNet(ContactEvents.DELETE_CONTACT_SUCCESS, _source);
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_DELETE_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- contactsLogger.error(`Failed to delete contact, ${e.message}`, {
- source: _source,
- });
- emitNet(ContactEvents.ACTION_RESULT, _source, {
- message: 'CONTACT_DELETE_FAILED',
- type: 'error',
- });
- }
-});
diff --git a/resources/server/sv_main.ts b/resources/server/sv_main.ts
index 80818ac..3df0fe1 100644
--- a/resources/server/sv_main.ts
+++ b/resources/server/sv_main.ts
@@ -1,7 +1,8 @@
import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
import { mainLogger } from './sv_logger';
import { PhoneEvents } from '../../typings/phone';
+import PlayerService from './players/player.service';
+import { getSource } from './utils/miscUtils';
interface Credentials {
phone_number: string;
@@ -18,7 +19,7 @@ async function getCredentials(identifier: string): Promise {
onNet('phone:getCredentials', async () => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const number = await getCredentials(identifier);
emitNet(PhoneEvents.SEND_CREDENTIALS, _source, number);
} catch (e) {
diff --git a/resources/server/sv_marketplace.ts b/resources/server/sv_marketplace.ts
deleted file mode 100644
index 617cd0f..0000000
--- a/resources/server/sv_marketplace.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-import { getIdentifier, getPlayer, getSource } from './functions';
-import { pool } from './db';
-import { mainLogger } from './sv_logger';
-import { MarketplaceListing } from '../../typings/marketplace';
-import { reportListingToDiscord } from './discord';
-import { MarketplaceEvents } from '../../typings/marketplace';
-
-const selloutLogger = mainLogger.child({ module: 'sellout' });
-
-async function fetchAllListings(): Promise {
- const query = 'SELECT * FROM npwd_marketplace_listings ORDER BY id DESC';
-
- const [results] = await pool.query(query);
- return results;
-}
-
-async function addListing(
- identifier: string,
- username: string,
- name: string,
- number: any,
- listing: MarketplaceListing,
-): Promise {
- const query =
- 'INSERT INTO npwd_marketplace_listings (identifier, username, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?, ?)';
- await pool.query(query, [
- identifier,
- username,
- name,
- number,
- listing.title,
- listing.url,
- listing.description,
- ]);
-}
-
-async function deleteListing(listingId: number, identifier: string): Promise {
- 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_marketplace_listings WHERE id = ?`;
- const [results] = await pool.query(query, [listingId]);
- const listings = results;
- return listings[0];
-}
-
-async function reportListing(listingId: number, profile: string): Promise {
- const query = `INSERT INTO npwd_marketplace_reports (listing_id, profile) VALUES (?, ?)`;
-
- await pool.query(query, [listingId, profile]);
-}
-
-async function doesReportExist(listingId: number, profile: string): Promise {
- const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`;
- const [results] = await pool.query(query, [listingId, profile]);
- const result = results;
-
- return result.length > 0;
-}
-
-onNet(MarketplaceEvents.FETCH_LISTING, async () => {
- const _source = getSource();
- try {
- const listings = await fetchAllListings();
- emitNet(MarketplaceEvents.SEND_LISTING, _source, listings);
- } catch (e) {
- selloutLogger.error(`Failed to fetch listings, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(MarketplaceEvents.ADD_LISTING, async (listing: MarketplaceListing) => {
- const _source = getSource();
- try {
- const player = getPlayer(_source);
-
- // This is used as username for the reports
- await addListing(
- player.identifier,
- player.username,
- player.getName(),
- player.getPhoneNumber(),
- listing,
- );
-
- emitNet(MarketplaceEvents.ADD_LISTING_SUCCESS, _source);
- emitNet(MarketplaceEvents.ACTION_RESULT, _source, {
- message: 'MARKETPLACE_CREATE_LISTING_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- selloutLogger.error(`Failed to add listing ${e.message}`, {
- source: _source,
- });
-
- emitNet(MarketplaceEvents.ACTION_RESULT, _source, {
- message: 'MARKETPLACE_CREATE_LISTING_FAILED',
- type: 'error',
- });
- }
-});
-
-onNet(MarketplaceEvents.DELETE_LISTING, async (listingId: number) => {
- const pSource = getSource();
- try {
- const identifier = getIdentifier(pSource);
-
- await deleteListing(listingId, identifier);
-
- // fetches the listings again
- emitNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, pSource);
-
- emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
- message: 'MARKETPLACE_DELETE_LISTING_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- selloutLogger.error(`Failed to delete listing ${e.message}`, {
- source: pSource,
- });
- emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
- message: 'MARKETPLACE_DELETE_LISTING_FAILED',
- type: 'error',
- });
- }
-});
-
-onNet(MarketplaceEvents.REPORT_LISTING, async (listing: MarketplaceListing) => {
- const pSource = getSource();
-
- try {
- const rListing = await getListing(listing.id);
- const reportExists = await doesReportExist(listing.id, listing.name);
-
- // gets the player name (steam) of the player that is reporting
- const reportingPlayer = GetPlayerName(pSource);
- if (reportExists) {
- // send an info alert
- selloutLogger.error(`This listing has already been reported`);
- return emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
- message: 'MARKETPLACE_REPORT_LISTING_FAILED',
- type: 'info',
- });
- }
-
- await reportListing(rListing.id, rListing.name);
- await reportListingToDiscord(rListing, reportingPlayer);
-
- emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
- message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- selloutLogger.error(`Failed to report listing ${e.message}`, {
- source: pSource,
- });
- }
-});
diff --git a/resources/server/sv_match.ts b/resources/server/sv_match.ts
index 33b0273..569a0d8 100644
--- a/resources/server/sv_match.ts
+++ b/resources/server/sv_match.ts
@@ -1,11 +1,12 @@
-import { ResultSetHeader, RowDataPacket } from 'mysql2';
+import { ResultSetHeader } from 'mysql2';
import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
import { config } from './server';
import { Like, Match, Profile, MatchEvents, NewProfile } from '../../typings/match';
import { mainLogger } from './sv_logger';
-import { generateProfileName } from './players/sv_players';
+import { generateProfileName } from './utils/generateProfileName';
+import { getSource } from './utils/miscUtils';
+import PlayerService from './players/player.service';
const matchLogger = mainLogger.child({ module: 'match' });
const DEFAULT_IMAGE = 'https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg';
@@ -252,7 +253,7 @@ async function dispatchProfiles(identifier: string, source: number): Promise {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
matchLogger.debug(`Initializing match for identifier: ${identifier}`);
await dispatchPlayerProfile(identifier, _source);
@@ -262,7 +263,7 @@ onNet(MatchEvents.INITIALIZE, async () => {
onNet(MatchEvents.CREATE_MY_PROFILE, async (profile: Profile) => {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
matchLogger.debug(`Creating profile for identifier: ${identifier}`);
matchLogger.debug(profile);
@@ -284,7 +285,7 @@ onNet(MatchEvents.CREATE_MY_PROFILE, async (profile: Profile) => {
onNet(MatchEvents.UPDATE_MY_PROFILE, async (profile: Profile) => {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
matchLogger.debug(`Updating profile for identifier: ${identifier}`);
matchLogger.debug(profile);
@@ -306,7 +307,7 @@ onNet(MatchEvents.UPDATE_MY_PROFILE, async (profile: Profile) => {
onNet(MatchEvents.SAVE_LIKES, async (likes: Like[]) => {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
matchLogger.debug(`Saving likes for identifier ${identifier}`);
try {
@@ -334,7 +335,7 @@ onNet(MatchEvents.SAVE_LIKES, async (likes: Like[]) => {
onNet(MatchEvents.GET_MATCHES, async () => {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
try {
const matchedProfiles = await findAllMatches(identifier);
diff --git a/resources/server/sv_messages.ts b/resources/server/sv_messages.ts
deleted file mode 100644
index bb411ef..0000000
--- a/resources/server/sv_messages.ts
+++ /dev/null
@@ -1,564 +0,0 @@
-import {
- CreateMessageGroupResult,
- Message,
- MessageGroup,
- MessageEvents,
-} from '../../typings/messages';
-import { pool, withTransaction } from './db';
-import { getIdentifier, getSource, getPlayerFromIdentifier } from './functions';
-import { mainLogger } from './sv_logger';
-
-const messageLogger = mainLogger.child({ module: 'messages' });
-
-/**
- * Used for the raw npwd_messages_groups row responses
- */
-interface UnformattedMessageGroup {
- group_id: string;
- user_identifier: string;
- participant_identifier: string;
- phone_number: string;
- label?: string;
- avatar?: string;
- display?: string;
- updatedAt: string;
- unreadCount: number;
-}
-
-/**
- * Used to help consolidate raw npwd_messages_groups rows into
- * a mapping of a single message group
- */
-interface MessageGroupMapping {
- [groupId: string]: {
- user_identifier: string;
- // Participant displays
- participants: string[];
- phoneNumbers: string[];
- label?: string;
- avatar?: string;
- updatedAt: string;
- unreadCount: number;
- };
-}
-
-/**
- * Create a message in the database
- * @param userIdentifier - identifier of the user creating this message
- * @param groupId - the message group ID to attach this message to
- * @param message - content of the message
- * @param participants -
- */
-async function createMessage(
- userIdentifier: string,
- groupId: string,
- message: string,
- participants: string[],
-): Promise {
- const query = `
- INSERT INTO npwd_messages
- (user_identifier, message, group_id)
- VALUES (?, ?, ?)
- `;
-
- const groupQuery = `
- UPDATE npwd_messages_groups SET unreadCount = unreadCount + 1 WHERE participant_identifier = ? AND group_id = ?
- `;
-
- const [results] = await pool.query(query, [userIdentifier, message, groupId]);
-
- // updates unreadCount for all participants
- await Promise.all(
- participants
- .filter((s) => userIdentifier !== s)
- .map((s) => pool.query(groupQuery, [s, groupId])),
- );
-
- return results;
-}
-
-/**
- * Retrieve all message groups associated with a user. This will
- * populate the list of message groups on the UI
- * @param userIdentifier - identifier of the user to get message groups for
- */
-async function getMessageGroups(userIdentifier: string): Promise {
- const query = `
- SELECT
- npwd_messages_groups.unreadCount,
- npwd_messages_groups.group_id,
- npwd_messages_groups.participant_identifier,
- npwd_messages_groups.user_identifier,
- npwd_messages_labels.label,
- users.phone_number,
- npwd_phone_contacts.avatar,
- npwd_phone_contacts.display
- FROM (
- SELECT group_id
- FROM npwd_messages_groups
- WHERE npwd_messages_groups.participant_identifier = ?
- ) as t
- LEFT OUTER JOIN npwd_messages_groups on npwd_messages_groups.group_id = t.group_id
- LEFT OUTER JOIN users on users.identifier = npwd_messages_groups.participant_identifier
- LEFT OUTER JOIN npwd_messages_labels on npwd_messages_labels.group_id = npwd_messages_groups.group_id
- LEFT OUTER JOIN npwd_phone_contacts on REGEXP_REPLACE(npwd_phone_contacts.number, '[^0-9]', '') = REGEXP_REPLACE(users.phone_number, '[^0-9]', '') AND npwd_phone_contacts.identifier = ?
- ORDER BY npwd_messages_groups.createdAt DESC
- `;
- const [results] = await pool.query(query, [userIdentifier, userIdentifier, userIdentifier]);
- return results;
-}
-
-/**
- * Retrieve all messages associated with a group and add a field
- * "isMine" which determines if the message belongs to the user
- * making the request
- * @param userIdentifier - user to get messages for
- * @param groupId - the group to get messages from
- */
-async function getMessages(userIdentifier: string, groupId: string): Promise {
- const query = `
- SELECT
- npwd_messages.id,
- npwd_messages.message,
- npwd_messages.group_id,
- npwd_messages.user_identifier,
- npwd_messages.isRead,
- npwd_messages.updatedAt,
- users.phone_number,
- npwd_phone_contacts.display,
- npwd_phone_contacts.avatar
- FROM npwd_messages
- LEFT OUTER JOIN users on users.identifier = npwd_messages.user_identifier
- LEFT OUTER JOIN npwd_phone_contacts on REGEXP_REPLACE(npwd_phone_contacts.number, '[^0-9]', '') = REGEXP_REPLACE(users.phone_number, '[^0-9]', '') AND npwd_phone_contacts.identifier = ?
- WHERE npwd_messages.group_id = ?
- ORDER BY createdAt ASC;
- `;
- const [results] = await pool.query(query, [userIdentifier, groupId]);
- const messages = results;
- return messages.map((message) => ({
- ...message,
- isMine: message.user_identifier === userIdentifier,
- updatedAt: message.updatedAt.toString(),
- }));
-}
-
-/**
- * Create a message group label
- * @param userIdentifier - user who is creating the message group
- * @param groupId - groupId this label is attached to
- * @param label - the label itself
- */
-async function createLabel(userIdentifier: string, groupId: string, label: string): Promise {
- const query = `
- INSERT INTO npwd_messages_labels
- (user_identifier, group_id, label)
- VALUES (?, ?, ?)
- `;
- await pool.query(query, [userIdentifier, groupId, label]);
-}
-
-/**
- * Create a message group
- * @param userIdentifier - the user creating the message group
- * @param groupId - the unique group ID this corresponds to
- * @param participantIdentifier - the participant user identifier. This identifier is what attaches
- * other players to the message group
- */
-async function createMessageGroup(
- userIdentifier: string,
- groupId: string,
- participantIdentifier: string,
-): Promise {
- const query = `
- INSERT INTO npwd_messages_groups
- (user_identifier, group_id, participant_identifier)
- VALUES (?, ?, ?)
- `;
- await pool.query(query, [userIdentifier, groupId, participantIdentifier]);
-}
-
-/**
- * Find a players identifier from their phone number
- * @param phoneNumber - the phone number to search for
- */
-async function getIdentifierFromPhoneNumber(phoneNumber: string): Promise {
- const query = `
- SELECT identifier
- FROM users
- WHERE REGEXP_REPLACE(phone_number, '[^0-9]', '') = ?
- LIMIT 1
- `;
- const [results] = await pool.query(query, [phoneNumber]);
- const identifiers = results;
- return identifiers[0]['identifier'];
-}
-
-/**
- * This method checks if the input groupId already exists in
- * the database. As long as the groupId is derived from the input
- * identifiers this means that the user is trying to create a
- * duplicate!
- * @param groupId - group Id to check that it exists
- */
-async function checkIfMessageGroupExists(groupId: string): Promise {
- const query = `
- SELECT COUNT(*) as count
- FROM npwd_messages_groups
- WHERE group_id = ?;
- `;
- const [results] = await pool.query(query, [groupId]);
- const result = results;
- const count = result[0].count;
- return count > 0;
-}
-
-async function getMessageCountByGroup(groupId: string): Promise {
- const query = `
- SELECT COUNT(*) as count
- FROM npwd_messages
- WHERE group_id = ?;
- `;
- const [results] = await pool.query(query, [groupId]);
- const result = results;
- return result[0].count;
-}
-
-/**
- * Consolidate raw message groups into a mapping that groups participants
- * by the message group. The goal of this is to reduce the rows of message
- * groups into a single MessageGroup object.
- * @param userIdentifier - the user identifier to get message groups for
- */
-async function getConsolidatedMessageGroups(userIdentifier: string): Promise {
- const messageGroups = await getMessageGroups(userIdentifier);
- return messageGroups.reduce(
- (mapping: MessageGroupMapping, messageGroup: UnformattedMessageGroup) => {
- const groupId = messageGroup.group_id;
- const displayTerm = messageGroup.display || messageGroup.phone_number || '???';
- const isUser = messageGroup.participant_identifier === userIdentifier;
- // Is already mapped?
- if (groupId in mapping) {
- // Add participant phone number
- mapping[groupId].phoneNumbers = mapping[groupId].phoneNumbers.concat(
- messageGroup.phone_number,
- );
- if (isUser) {
- // Add unread count if its user's message group
- mapping[groupId].unreadCount = messageGroup.unreadCount;
- return mapping;
- }
- // Add participant if its not user's message group
- mapping[groupId].participants = mapping[groupId].participants.concat(displayTerm);
- return mapping;
- }
- if (isUser) {
- // Group not mapped and its current user
- mapping[groupId] = {
- user_identifier: messageGroup.user_identifier,
- unreadCount: messageGroup.unreadCount,
- avatar: null,
- label: null,
- participants: [],
- phoneNumbers: [messageGroup.phone_number],
- updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
- };
- return mapping;
- }
- // Group not mapped and its not current user
- mapping[groupId] = {
- user_identifier: messageGroup.user_identifier,
- unreadCount: 0,
- avatar: messageGroup.avatar,
- label: messageGroup.label,
- participants: [displayTerm],
- phoneNumbers: [messageGroup.phone_number],
- updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
- };
- return mapping;
- },
- {},
- );
-}
-
-async function getGroupIds(
- userIdentifier: string,
- groupMapping: MessageGroupMapping,
-): Promise {
- const groupIds: string[] = [];
- for (const groupId of Object.keys(groupMapping)) {
- const isMine = groupMapping[groupId].user_identifier === userIdentifier;
- if (isMine || (await getMessageCountByGroup(groupId)) > 0) {
- groupIds.push(groupId);
- }
- }
- return groupIds;
-}
-
-/**
- * Given the mapping of groupId: fields contents reduce it into a list
- * of MessageGroup objects ready for the UI to consume
- * @param userIdentifier - user to generate the MessageGroups for
- */
-async function getFormattedMessageGroups(userIdentifier: string): Promise {
- const groupMapping = await getConsolidatedMessageGroups(userIdentifier);
- const groupIds = await getGroupIds(userIdentifier, groupMapping);
-
- return groupIds.map((groupId) => {
- const group = groupMapping[groupId];
- return {
- ...group,
- groupId,
- groupDisplay: group.participants.join(', '),
- // note that the 1 here references how many participants besides the user
- isGroupChat: group.participants.length > 1,
- };
- });
-}
-
-/**
- * Create the same unique ID from an identifiers array.
- * They will be always be sorted to ensure always the same ID.
- * @param identifiers array of player identifiers
- */
-function createGroupHashID(identifiers: string[]) {
- // make sure we are always in a consistent order. It is very important
- // that this not change! Changing this order can result in the ability
- // of duplicate message groups being created.
- identifiers.sort();
- const mergedIdentifiers = identifiers.join('+');
- // we don't need this to be secure. Its purpose is to create a unique
- // string derived from the identifiers. In this way we can check
- // that this groupId isn't used before. If it has then it means
- // we are trying to create a duplicate message group!
- return mergedIdentifiers;
-}
-
-/**
- * Main method to handle creation of new message groups. First
- * we retrieve identifiers for each submitted phone number and
- * then rows in npwd_messages_groups are created for each of them
- * bound to a unique groupId. The groupId is any unique string - we
- * use hashes here.
- *
- * These queries are batched with a transaction so that if any of
- * them fail the queries are not committed to the database. This helps
- * avoid situations where some participants get added to the group but
- * one fails resulting in a partial group which would be very confusing
- * to the player.
- * @param userIdentifier - user who is creating the group
- * @param phoneNumbers - list of phone numbers to add to the grup
- * @param groupLabel - optional group label to give the group
- */
-async function createMessageGroupsFromPhoneNumbers(
- userIdentifier: string,
- phoneNumbers: string[],
- groupLabel: string,
-): Promise {
- // we check that each phoneNumber exists before we create the group
- const identifiers: string[] = [];
- const failedNumbers: string[] = [];
-
- for (const phoneNumber of phoneNumbers) {
- try {
- const identifier = await getIdentifierFromPhoneNumber(phoneNumber);
- identifiers.push(identifier);
- } catch (e) {
- failedNumbers.push(phoneNumber);
- }
- }
-
- if (phoneNumbers.length === failedNumbers.length) {
- return { error: true, allNumbersFailed: true, failedNumbers };
- }
-
- // don't allow explicitly adding yourself
- if (identifiers.some((identifier) => identifier === userIdentifier)) {
- return { error: true, mine: true, failedNumbers };
- }
-
- const groupId = createGroupHashID([userIdentifier, ...identifiers]);
- if (await checkIfMessageGroupExists(groupId)) {
- return { error: false, duplicate: true, groupId, identifiers, failedNumbers };
- }
-
- const queryPromises = [
- // create a row that contains ourselves so reverse accessing from
- // other players works as expected
- createMessageGroup(userIdentifier, groupId, userIdentifier),
- ...identifiers.map((identifier) => createMessageGroup(userIdentifier, groupId, identifier)),
- ];
-
- // we allow users to attach labels to name their group chats
- if (groupLabel) {
- queryPromises.push(createLabel(userIdentifier, groupId, groupLabel));
- }
-
- // wrap this in a transaction to make sure ALL of these INSERTs succeed
- // so we are not left in a situation where only some of the member of the
- // group exist while other are left off.
- await withTransaction(queryPromises);
-
- return { error: false, groupId, identifiers, failedNumbers };
-}
-
-// getting the participants from groupId.
-// this should return the source or and array of identifiers
-function getIdentifiersFromParticipants(groupId: string) {
- return groupId.split('+');
-}
-
-/**
- * Sets the current message isRead to 0 for said player
- * @param groupId The unique group ID for the message
- * @param identifier The identifier for the player
- */
-async function setMessageRead(groupId: string, identifier: string) {
- const query =
- 'UPDATE npwd_messages_groups SET unreadCount = 0 WHERE group_id = ? AND participant_identifier = ?';
- await pool.query(query, [groupId, identifier]);
-}
-
-onNet(MessageEvents.FETCH_MESSAGE_GROUPS, async () => {
- const _source = getSource();
- try {
- const identifier = getIdentifier(_source);
- const messageGroups = await getFormattedMessageGroups(identifier);
- emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS, _source, messageGroups);
- } catch (e) {
- emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_FAILED, _source);
- messageLogger.error(`Failed to fetch messages groups, ${e.message}`);
- }
-});
-
-onNet(MessageEvents.CREATE_MESSAGE_GROUP, async (phoneNumbers: string[], label: string = null) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
-
- if (result.error && result.allNumbersFailed) {
- emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, _source, result);
- return emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_ALL_NUMBERS_FAILED`,
- type: 'error',
- });
- }
-
- if (result.error) {
- emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, _source, result);
- return emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED`,
- type: 'error',
- });
- }
-
- if (result.failedNumbers.length === 1) {
- emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_ONE_NUMBER_FAILED`,
- type: 'warning',
- options: { number: result.failedNumbers[0] },
- });
- }
-
- if (result.failedNumbers.length > 1) {
- emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_SOME_NUMBERS_FAILED`,
- type: 'warning',
- options: { numbers: result.failedNumbers.join(', ') },
- });
- }
-
- emitNet(MessageEvents.CREATE_MESSAGE_GROUP_SUCCESS, _source, result);
- if (result.duplicate) {
- return;
- }
-
- if (result.identifiers) {
- for (const participantId of result.identifiers) {
- // we don't broadcast to the source of the event.
- if (participantId !== _identifier) {
- const participantPlayer = getPlayerFromIdentifier(participantId);
- if (!participantPlayer) {
- return;
- }
- emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, participantPlayer.source);
- }
- }
- }
- } catch (e) {
- emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, _source);
- emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: `APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED`,
- type: 'error',
- });
- messageLogger.error(`Failed to create message group, ${e.message}`, {
- source: _source,
- e,
- });
- }
-});
-
-onNet(MessageEvents.FETCH_MESSAGES, async (groupId: string) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- const messages = await getMessages(_identifier, groupId);
- emitNet(MessageEvents.FETCH_MESSAGES_SUCCESS, _source, messages);
- } catch (e) {
- emitNet(MessageEvents.FETCH_MESSAGES_FAILED, _source);
- messageLogger.error(`Failed to fetch messages, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(MessageEvents.SEND_MESSAGE, async (groupId: string, message: string, groupName: string) => {
- const _source = getSource();
- try {
- const _identifier = getIdentifier(_source);
- const userParticipants = getIdentifiersFromParticipants(groupId);
-
- await createMessage(_identifier, groupId, message, userParticipants);
-
- emitNet(MessageEvents.SEND_MESSAGE_SUCCESS, _source, groupId);
-
- // gets the identifiers foe the participants for current groupId.
-
- for (const participantId of userParticipants) {
- // we don't broadcast to the source of the event.
- if (participantId !== _identifier) {
- const participantPlayer = getPlayerFromIdentifier(participantId);
- if (!participantPlayer) {
- return;
- }
- emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, participantPlayer.source);
- emitNet(MessageEvents.CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
- groupName,
- groupId,
- message,
- });
- }
- }
- } catch (e) {
- emitNet(MessageEvents.ACTION_RESULT, _source, {
- message: 'APPS_MESSAGES_NEW_MESSAGE_FAILED',
- type: 'error',
- });
- messageLogger.error(`Failed to send message, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(MessageEvents.SET_MESSAGE_READ, async (groupId: string) => {
- const pSource = getSource();
- try {
- const identifier = getIdentifier(pSource);
- await setMessageRead(groupId, identifier);
- emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, pSource);
- } catch (e) {
- messageLogger.error(`Failed to set message as read, ${e.message}`, {
- source: pSource,
- });
- }
-});
diff --git a/resources/server/sv_notes.ts b/resources/server/sv_notes.ts
deleted file mode 100644
index 64abca5..0000000
--- a/resources/server/sv_notes.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
-import { Note, NoteId, NotesEvents } from '../../typings/notes';
-import { mainLogger } from './sv_logger';
-
-const notesLogger = mainLogger.child({ module: 'notes' });
-
-async function addNote(identifier: string, note: Note): Promise {
- const query = 'INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)';
- await pool.query(query, [identifier, note.title, note.content]);
-}
-
-async function fetchAllNotes(identifier: string): Promise {
- const query = 'SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC';
- const [result] = await pool.query(query, [identifier]);
- return result;
-}
-
-async function deleteNote(noteId: number, identifier: string) {
- const query = 'DELETE FROM npwd_notes WHERE id = ? AND identifier = ?';
- await pool.query(query, [noteId, identifier]);
-}
-
-async function updateNote(note: Note, identifier: string): Promise {
- const query = 'UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?';
- await pool.query(query, [note.title, note.content, note.id, identifier]);
-}
-
-onNet(NotesEvents.ADD_NOTE, async (note: Note) => {
- const pSource = getSource();
- try {
- const _identifier = getIdentifier(pSource);
- await addNote(_identifier, note);
- emitNet(NotesEvents.SEND_NOTE_SUCCESS, pSource);
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_ADD_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- notesLogger.error(`Failed to add note ${e.message}`, {
- source: pSource,
- });
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_ADD_FAILED',
- type: 'error',
- });
- }
-});
-
-onNet(NotesEvents.FETCH_ALL_NOTES, async () => {
- const pSource = getSource();
- try {
- const _identifier = getIdentifier(pSource);
- const notes = await fetchAllNotes(_identifier);
- emitNet(NotesEvents.SEND_NOTE, pSource, notes);
- } catch (e) {
- notesLogger.error(`Failed to fetch notes ${e.message}`, {
- source: pSource,
- });
- }
-});
-
-onNet(NotesEvents.DELETE_NOTE, async (noteId: NoteId) => {
- const pSource = getSource();
- try {
- const _identifier = getIdentifier(pSource);
- await deleteNote(noteId.id, _identifier);
-
- emitNet(NotesEvents.DELETE_NOTE_SUCCESS, pSource);
-
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_DELETE_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- const pSource = (global as any).source;
- notesLogger.error(`Failed to delete note, ${e.message}`);
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_DELETE_FAILED',
- type: 'error',
- });
- }
-});
-
-onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
- const pSource = getSource();
- try {
- const _identifier = getIdentifier(pSource);
- await updateNote(note, _identifier);
- emitNet(NotesEvents.UPDATE_NOTE_SUCCESS, pSource);
-
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_UPDATE_SUCCESS',
- type: 'success',
- });
- } catch (e) {
- emitNet(NotesEvents.UPDATE_NOTE_FAILURE, pSource);
- notesLogger.error(`Failed to update note, ${e.message}`, {
- source: pSource,
- });
- emitNet(NotesEvents.ACTION_RESULT, pSource, {
- message: 'NOTES_UPDATE_FAILED',
- type: 'error',
- });
- }
-});
diff --git a/resources/server/sv_photo.ts b/resources/server/sv_photo.ts
deleted file mode 100644
index dabe839..0000000
--- a/resources/server/sv_photo.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
-import { GalleryPhoto, PhotoEvents } from '../../typings/photo';
-import { mainLogger } from './sv_logger';
-
-const photoLogger = mainLogger.child({ module: 'photo' });
-
-async function uploadPhoto(identifier: string, image: string): Promise {
- const query = 'INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)';
- const [results] = (await pool.query(query, [identifier, image])) as any;
- return { id: results.insertId, image };
-}
-
-async function getPhotosByIdentifier(identifier: string): Promise {
- const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
- const [results] = await pool.query(query, [identifier]);
- return results;
-}
-
-async function deletePhoto(photo: GalleryPhoto, identifier: string) {
- const query = 'DELETE FROM npwd_phone_gallery WHERE image = ? AND identifier = ?';
- await pool.query(query, [photo.image, identifier]);
-}
-
-onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
- const _source = getSource();
- try {
- const identifier = getIdentifier(_source);
- const photo = await uploadPhoto(identifier, image);
- emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, _source, photo);
- } catch (e) {
- photoLogger.error(`Failed to upload photo, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(PhotoEvents.FETCH_PHOTOS, async () => {
- const _source = getSource();
- try {
- const identifier = getIdentifier(_source);
- const photos = await getPhotosByIdentifier(identifier);
- emitNet(PhotoEvents.SEND_PHOTOS, _source, photos);
- } catch (e) {
- photoLogger.error(`Failed to fetch photos, ${e.message}`, {
- source: _source,
- });
- }
-});
-
-onNet(PhotoEvents.DELETE_PHOTO, async (photo: GalleryPhoto) => {
- const _source = getSource();
- try {
- const identifier = getIdentifier(_source);
- await deletePhoto(photo, identifier);
- emitNet(PhotoEvents.DELETE_PHOTO_SUCCESS, _source);
- } catch (e) {
- photoLogger.error(`Failed to fetch photos, ${e.message}`, {
- source: _source,
- });
- }
-});
diff --git a/resources/server/sv_twitter.ts b/resources/server/sv_twitter.ts
index f0d05bd..7ae7ce3 100644
--- a/resources/server/sv_twitter.ts
+++ b/resources/server/sv_twitter.ts
@@ -1,12 +1,13 @@
import { ResultSetHeader } from 'mysql2';
import { pool } from './db';
-import { getIdentifier, getSource } from './functions';
import { NewTweet, Tweet, Profile } from '../../typings/twitter';
import { config } from './server';
import { reportTweetToDiscord } from './discord';
import { mainLogger } from './sv_logger';
-import { generateProfileName, getDefaultProfileNames } from './players/sv_players';
+import PlayerService from './players/player.service';
import { TwitterEvents } from '../../typings/twitter';
+import { getSource } from './utils/miscUtils';
+import { generateProfileName } from './utils/generateProfileName';
const twitterLogger = mainLogger.child({ module: 'twitter' });
@@ -311,19 +312,23 @@ async function doesRetweetExist(tweetId: number, identifier: string): Promise {
const _source = getSource();
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
try {
const profile = await getOrCreateProfile(identifier);
// if we got null from getOrCreateProfile it means it doesn't exist and
// we failed to create it. In this case we pass the UI some default
- // profile names it can choose from
- if (!profile) {
- const defaultProfileNames = await getDefaultProfileNames(identifier);
- emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_NULL, _source, defaultProfileNames);
- } else {
- emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, _source, profile);
- }
+ // profile names it can choose from.
+
+ // We should be able to comment this out as profile **should** be guranteed,
+ // as we create a default profile in that process.
+
+ // if (!profile) {
+ // const defaultProfileNames = await getDefaultProfileNames(identifier);
+ // emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_NULL, _source, defaultProfileNames);
+ // } else {
+ emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, _source, profile);
+ // }
} catch (e) {
twitterLogger.error(`Failed to get or create profile, ${e.message}`, {
source: _source,
@@ -335,7 +340,7 @@ onNet(TwitterEvents.GET_OR_CREATE_PROFILE, async () => {
onNet(TwitterEvents.CREATE_PROFILE, async (profile: Profile) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
await createProfile(identifier, profile.profile_name);
emitNet(TwitterEvents.CREATE_PROFILE_RESULT, _source, {
message: 'TWITTER_CREATE_PROFILE_SUCCESS',
@@ -355,7 +360,7 @@ onNet(TwitterEvents.CREATE_PROFILE, async (profile: Profile) => {
onNet(TwitterEvents.UPDATE_PROFILE, async (profile: Profile) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
await updateProfile(identifier, profile);
emitNet(TwitterEvents.UPDATE_PROFILE_RESULT, _source, {
message: 'TWITTER_EDIT_PROFILE_SUCCESS',
@@ -375,7 +380,7 @@ onNet(TwitterEvents.UPDATE_PROFILE, async (profile: Profile) => {
onNet(TwitterEvents.FETCH_TWEETS, async () => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const profile = await getProfile(identifier);
if (!profile) {
twitterLogger.warn(
@@ -397,7 +402,7 @@ onNet(TwitterEvents.FETCH_TWEETS, async () => {
onNet(TwitterEvents.FETCH_TWEETS_FILTERED, async (searchValue: string) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const profile = await getProfile(identifier);
const tweets = await fetchTweetsFiltered(profile.id, searchValue);
emitNet(TwitterEvents.FETCH_TWEETS_FILTERED_SUCCESS, _source, tweets);
@@ -412,7 +417,7 @@ onNet(TwitterEvents.FETCH_TWEETS_FILTERED, async (searchValue: string) => {
onNet(TwitterEvents.CREATE_TWEET, async (tweet: Tweet) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const createdTweet = await createTweet(identifier, tweet);
emitNet(TwitterEvents.CREATE_TWEET_BROADCAST, -1, createdTweet);
} catch (e) {
@@ -429,7 +434,7 @@ onNet(TwitterEvents.CREATE_TWEET, async (tweet: Tweet) => {
onNet(TwitterEvents.DELETE_TWEET, async (tweetId: number) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
await deleteTweet(identifier, tweetId);
emitNet(TwitterEvents.DELETE_TWEET_SUCCESS, _source);
@@ -444,7 +449,7 @@ onNet(TwitterEvents.DELETE_TWEET, async (tweetId: number) => {
onNet(TwitterEvents.TOGGLE_LIKE, async (tweetId: number) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const profile = await getOrCreateProfile(identifier);
const likeExists = await doesLikeExist(profile.id, tweetId);
if (likeExists) {
@@ -464,7 +469,7 @@ onNet(TwitterEvents.TOGGLE_LIKE, async (tweetId: number) => {
onNet(TwitterEvents.RETWEET, async (tweetId: number) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
// alert the player that they have already retweeted
// this post (or that they are the original poster)
@@ -495,7 +500,7 @@ onNet(TwitterEvents.RETWEET, async (tweetId: number) => {
onNet(TwitterEvents.REPORT, async (tweetId: number) => {
const _source = getSource();
try {
- const identifier = getIdentifier(_source);
+ const identifier = PlayerService.getIdentifier(_source);
const profile = await getProfile(identifier);
const tweet = await getTweet(profile.id, tweetId);
diff --git a/resources/server/utils/PromiseNetEvents/PromiseResponse.ts b/resources/server/utils/PromiseNetEvents/PromiseResponse.ts
new file mode 100644
index 0000000..428a1ab
--- /dev/null
+++ b/resources/server/utils/PromiseNetEvents/PromiseResponse.ts
@@ -0,0 +1,91 @@
+import { FxServerRespError } from '../../../../typings/phone';
+import { JSONLike, PromiseRespStatus, RawDataResp } from './promise.types';
+import { netEventLogger } from './utils';
+import { config } from '../../server';
+
+// Meh temp maybe not idk.
+interface PromiseRespDebug {
+ /* Start time returned by process.hrtime()*/
+ started: [number, number];
+}
+
+export class PromiseResponse {
+ public readonly respEventName: string;
+ public readonly source: number;
+ private promiseRespDebug: PromiseRespDebug;
+ protected responseData: RawDataResp;
+
+ /**
+ * Create a new promise response context for use in the onNetPrommise,
+ * callback argument
+ *
+ * @param respEventName - The response event name to emit to on resp.send()
+ * @param source - The source of the player to emit back to
+ */
+ constructor(respEventName: string, source: number) {
+ this.respEventName = respEventName;
+ this.source = source;
+
+ this.promiseRespDebug = {
+ started: process.hrtime(),
+ };
+
+ this.responseData = {
+ body: {},
+ status: 'in-progress',
+ };
+ }
+
+ /**
+ * Will emit back to the client with the data assigned using
+ * `setData`. Will send all data assigned to the this.responseData
+ * back to the client to resolve the promise.
+ *
+ * @return void
+ */
+ public send(obj: JSONLike): void {
+ this.responseData.body = obj;
+ this.responseData.status = 'success';
+ emitNet(this.respEventName, this.source, this.responseData);
+
+ if (config.debug.level === 'silly') {
+ // Debug time data
+ const hrEnd = process.hrtime(this.promiseRespDebug.started);
+ // Divide by good old 1 x 10^6
+ const nanoToMicro = hrEnd[1] / 1e6;
+ const secondExec = hrEnd[0];
+
+ netEventLogger.silly(`Promise emitted to client after ${secondExec}s ${nanoToMicro}ms`);
+ }
+ }
+
+ /**
+ * Will change the status field present on promiseResponses, this doesn't
+ * really have a use for now except metadata
+ *
+ * @return void
+ */
+
+ public setStatus(status: PromiseRespStatus): this {
+ this.responseData.status = status;
+ return this;
+ }
+
+ /**
+ * Will emit back to the client with the data assigned using
+ * `setData`. Will send all data assigned to the this.responseData
+ * back to the client to resolve the promise.
+ *
+ * @return void
+ */
+ public sendError({ errorCode, message }: FxServerRespError): void {
+ this.responseData = {
+ error: {
+ errorCode,
+ message,
+ },
+ body: {},
+ status: 'error',
+ };
+ }
+}
diff --git a/resources/server/utils/PromiseNetEvents/onNetPromise.ts b/resources/server/utils/PromiseNetEvents/onNetPromise.ts
new file mode 100644
index 0000000..83d151a
--- /dev/null
+++ b/resources/server/utils/PromiseNetEvents/onNetPromise.ts
@@ -0,0 +1,33 @@
+import { ErrorStringKeys } from '../../../../typings/phone';
+import { getSource } from '../miscUtils';
+import { PromiseResponse } from './PromiseResponse';
+import { mainLogger } from '../../sv_logger';
+import { CBSignature, PromiseRequest, PromiseRequestData } from './promise.types';
+
+const netEventLogger = mainLogger.child({ module: 'events' });
+
+export function onNetPromise(eventName: string, cb: CBSignature) {
+ onNet(eventName, async (respEventName: string, data: PromiseRequestData) => {
+ const src = getSource();
+
+ const promiseRequest: PromiseRequest = {
+ source: src,
+ body: data,
+ };
+
+ // Lets hope GC can clean you up
+ const promiseResp = new PromiseResponse(respEventName, src);
+
+ // In case the cb is a promise, we use Promise.resolve
+ Promise.resolve(cb(promiseRequest, promiseResp)).catch((e) => {
+ netEventLogger.error(
+ `An error occured for a onNetPromise (${eventName}), Error: ${e.message}`,
+ );
+
+ promiseResp.sendError({
+ errorCode: ErrorStringKeys.SERVER_ERROR,
+ message: 'An error occured on the server',
+ });
+ });
+ });
+}
diff --git a/resources/server/utils/PromiseNetEvents/promise.types.ts b/resources/server/utils/PromiseNetEvents/promise.types.ts
new file mode 100644
index 0000000..1afe60d
--- /dev/null
+++ b/resources/server/utils/PromiseNetEvents/promise.types.ts
@@ -0,0 +1,30 @@
+import { FxServerRespError } from '../../../../typings/phone';
+import { PromiseResponse } from './PromiseResponse';
+
+export type BasicPrimitives = string | number | boolean;
+
+export interface JSONLike {
+ [key: string]: BasicPrimitives;
+}
+
+export type PromiseRespStatus = 'error' | 'success' | 'warning' | 'in-progress';
+
+export interface RawDataResp {
+ status: PromiseRespStatus;
+ error?: FxServerRespError;
+ body: JSONLike;
+}
+
+export interface PromiseRequest {
+ body: PromiseRequestData;
+ source: number;
+}
+
+export interface PromiseRequestData {
+ data: T;
+}
+
+export type CBSignature = (
+ request: PromiseRequest,
+ response: PromiseResponse,
+) => Promise | void;
diff --git a/resources/server/utils/PromiseNetEvents/utils.ts b/resources/server/utils/PromiseNetEvents/utils.ts
new file mode 100644
index 0000000..93e2fb6
--- /dev/null
+++ b/resources/server/utils/PromiseNetEvents/utils.ts
@@ -0,0 +1,5 @@
+import { mainLogger } from '../../sv_logger';
+
+export const netEventLogger = mainLogger.child({
+ module: 'net-events',
+});
diff --git a/resources/server/utils/ServerConstants.ts b/resources/server/utils/ServerConstants.ts
new file mode 100644
index 0000000..ecd989f
--- /dev/null
+++ b/resources/server/utils/ServerConstants.ts
@@ -0,0 +1,5 @@
+export enum FetchDefaultLimits {
+ NOTES_FETCH_LIMIT = 20,
+ CALLS_FETCH_LIMIT = 50,
+ CONTACTS_FETCH_LIMIT = 20,
+}
diff --git a/resources/server/utils/generateProfileName.ts b/resources/server/utils/generateProfileName.ts
new file mode 100644
index 0000000..cbaf84a
--- /dev/null
+++ b/resources/server/utils/generateProfileName.ts
@@ -0,0 +1,28 @@
+import PlayerService from '../players/player.service';
+import { clean } from './miscUtils';
+/**
+ * Generate a profile name by the player's name and/or phone number
+ * @param identifier - player's identifier
+ * @param delimiter - What we split the profile name by, defaults to -
+ */
+export async function generateProfileName(
+ identifier: string,
+ delimiter: string = '_',
+): Promise {
+ const player = PlayerService.getPlayerFromIdentifier(identifier);
+
+ const firstname = clean(player.getFirstName());
+ const lastname = clean(player.getLastName());
+ const phone_number = clean(player.getPhoneNumber());
+
+ if (firstname && lastname) {
+ return `${firstname}${delimiter}${lastname}`;
+ } else if (firstname) {
+ return firstname;
+ } else if (lastname) {
+ return lastname;
+ } else if (phone_number) {
+ return phone_number;
+ }
+ return null;
+}
diff --git a/resources/server/utils/getPlayerGameLicense.ts b/resources/server/utils/getPlayerGameLicense.ts
new file mode 100644
index 0000000..17ed0ad
--- /dev/null
+++ b/resources/server/utils/getPlayerGameLicense.ts
@@ -0,0 +1,15 @@
+export const getPlayerGameLicense = (src: number): null | string => {
+ // Parse specifically for license identifier as its
+ // guaranteed
+ const playerIdentifiers = getPlayerIdentifiers(src.toString());
+
+ let playerIdentifier;
+ for (const identifier of playerIdentifiers) {
+ if (identifier.includes('license:')) {
+ playerIdentifier = identifier.split(':')[1];
+ }
+ }
+
+ if (!playerIdentifier) return null;
+ return playerIdentifier;
+};
diff --git a/resources/server/utils/getRandomPhoneNumber.ts b/resources/server/utils/getRandomPhoneNumber.ts
new file mode 100644
index 0000000..d1f48c5
--- /dev/null
+++ b/resources/server/utils/getRandomPhoneNumber.ts
@@ -0,0 +1,13 @@
+import { config } from '../server';
+
+export function getRandomPhoneNumber() {
+ if (!config.general.useDashNumber) {
+ return Math.floor(Math.random() * 10000000).toString(); // 10000000 creates a number with 7 characters.
+ }
+
+ return Math.floor(Math.random() * 10000000)
+ .toString()
+ .replace(/(\d{3})(\d{4})/, '$1-$2');
+ // The numbers inside {} in replace() can be changed to how many digits you want on each side of the dash.
+ // Example: 123-4567
+}
diff --git a/resources/server/utils/miscUtils.ts b/resources/server/utils/miscUtils.ts
new file mode 100644
index 0000000..72d8787
--- /dev/null
+++ b/resources/server/utils/miscUtils.ts
@@ -0,0 +1,5 @@
+// Will apply any type to source
+export const getSource = () => (global as any).source;
+
+// Will clean string of any character that isn't 0-9, or a-z
+export const clean = (input: string) => (input ? input.replace(/[^0-9a-z]/gi, '') : input);
diff --git a/resources/yarn.lock b/resources/yarn.lock
index cd05599..38d6508 100644
--- a/resources/yarn.lock
+++ b/resources/yarn.lock
@@ -912,6 +912,11 @@
enabled "2.0.x"
kuler "^2.0.0"
+"@discordjs/collection@^0.1.6":
+ version "0.1.6"
+ resolved "https://registry.yarnpkg.com/@discordjs/collection/-/collection-0.1.6.tgz#9e9a7637f4e4e0688fd8b2b5c63133c91607682c"
+ integrity sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==
+
"@eslint/eslintrc@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.0.tgz#99cc0a0584d72f1df38b900fb062ba995f395547"
@@ -3720,9 +3725,9 @@ homedir-polyfill@^1.0.1:
parse-passwd "^1.0.0"
hosted-git-info@^2.1.4:
- version "2.8.8"
- resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
- integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
+ version "2.8.9"
+ resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
+ integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
html-encoding-sniffer@^2.0.1:
version "2.0.1"
@@ -6310,9 +6315,9 @@ sshpk@^1.7.0:
tweetnacl "~0.14.0"
ssri@^6.0.1:
- version "6.0.1"
- resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
- integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
+ integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==
dependencies:
figgy-pudding "^3.5.1"
diff --git a/typings/call.ts b/typings/call.ts
index 0e3dd25..a3edf59 100644
--- a/typings/call.ts
+++ b/typings/call.ts
@@ -33,4 +33,6 @@ export enum CallEvents {
SET_CALLER = 'npwd:setCaller',
SET_CALL_MODAL = 'npwd:callModal',
SET_CALL_HISTORY = 'npwd:setCallHistory',
+ ACTION_RESULT = 'npwd:callsActionResult',
+ SEND_ALERT = 'npwd:callSetAlert',
}
diff --git a/typings/config.ts b/typings/config.ts
index ec11899..a8f83ae 100644
--- a/typings/config.ts
+++ b/typings/config.ts
@@ -17,12 +17,13 @@ interface MatchConfig {
allowEditableProfileName: boolean;
}
interface Debug {
- level: 'error' | 'warn' | 'info' | 'verbose' | 'debug';
+ level: 'error' | 'warn' | 'info' | 'verbose' | 'debug' | 'silly';
enabled: boolean;
}
interface General {
useDashNumber: boolean;
+ enableMultiChar: boolean;
}
interface NotificationConfig {
@@ -34,7 +35,14 @@ interface BankConfig {
showNotifications: boolean;
}
+
+interface DatabaseConfig {
+ playerTable: string;
+ identifierColumn: string;
+}
+
export interface ResourceConfig {
+ database: DatabaseConfig;
Locale: string;
KeyTogglePhone: number;
KeyTakeCall: number;
diff --git a/typings/contact.ts b/typings/contact.ts
index ffbe230..42ab22e 100644
--- a/typings/contact.ts
+++ b/typings/contact.ts
@@ -11,13 +11,16 @@ export interface IContactAlert {
setAlert: (type: string) => void;
}
-export interface Contact {
- id: number;
+export interface PreDBContact {
display: string;
number: string;
avatar?: string;
}
+export interface Contact extends PreDBContact {
+ id: number;
+}
+
export enum ContactEvents {
SEND_CONTACTS = 'npwd:sendContacts',
GET_CONTACTS = 'npwd:getContacts',
@@ -29,4 +32,5 @@ export enum ContactEvents {
UPDATE_CONTACT_SUCCESS = 'npwd:updateContactSuccess',
ACTION_RESULT = 'npwd:contactActionResult',
SEND_ALERT = 'npwd:contactSetAlert',
+ MAIN_CLIENT_LISTER = 'npwd:contactMainListener',
}
diff --git a/typings/messages.ts b/typings/messages.ts
index ae90b45..6352c8f 100644
--- a/typings/messages.ts
+++ b/typings/messages.ts
@@ -23,6 +23,38 @@ export interface MessageGroup {
participants: string[];
}
+/**
+ * Used for the raw npwd_messages_groups row responses
+ */
+export interface UnformattedMessageGroup {
+ group_id: string;
+ user_identifier: string;
+ participant_identifier: string;
+ phone_number: string;
+ label?: string;
+ avatar?: string;
+ display?: string;
+ updatedAt: string;
+ unreadCount: number;
+}
+
+/**
+ * Used to help consolidate raw npwd_messages_groups rows into
+ * a mapping of a single message group
+ */
+export interface MessageGroupMapping {
+ [groupId: string]: {
+ user_identifier: string;
+ // Participant displays
+ participants: string[];
+ phoneNumbers: string[];
+ label?: string;
+ avatar?: string;
+ updatedAt: string;
+ unreadCount: number;
+ };
+}
+
export interface CreateMessageGroupResult {
error?: boolean;
phoneNumber?: string;
diff --git a/typings/notes.ts b/typings/notes.ts
index 33373dd..c33cae8 100644
--- a/typings/notes.ts
+++ b/typings/notes.ts
@@ -1,3 +1,5 @@
+import { IAlertProps } from './alerts';
+
export type AlertCategory =
| 'NOTES_ADD_SUCCESS'
| 'NOTES_ADD_FAILED'
@@ -17,10 +19,6 @@ export interface Note {
content: string;
}
-export interface NoteId {
- id: number;
-}
-
export enum NotesEvents {
ADD_NOTE = 'npwd:addNote',
FETCH_ALL_NOTES = 'npwd:fetchAllNotes',
@@ -33,4 +31,13 @@ export enum NotesEvents {
UPDATE_NOTE_FAILURE = 'npwd:updateNoteFailure',
ACTION_RESULT = 'npwd:notesActionResult',
SEND_ALERT = 'npwd:notesSetAlert',
+ SERVER_RESP = 'npwd:notesServerResp',
+}
+
+export interface NoteServerResponse {
+ alert?: IAlertProps;
+ action: 'SEND' | 'UPDATE' | 'DELETE' | 'ADD';
+ suceeded: boolean;
+ refetch?: boolean;
+ data?: T;
}
diff --git a/typings/phone.ts b/typings/phone.ts
index 7de8f12..3582d94 100644
--- a/typings/phone.ts
+++ b/typings/phone.ts
@@ -6,7 +6,7 @@ export enum PhoneEvents {
OPEN_APP_CONTACTS = 'npwd:app:CONTACTS',
OPEN_APP_BANK = 'npwd:app:BANK',
OPEN_APP_NOTES = 'npwd:app:NOTES',
- OPEN_APP_LISTINGS = 'npwd:app:SELLOUT',
+ OPEN_APP_LISTINGS = 'npwd:app:MARKETPLACE',
OPEN_APP_CAMERA = 'npwd:app:CAMERA',
OPEN_APP_DAILER = 'npwd:app:DIALER',
OPEN_PHONE = 'npwd:open',
@@ -20,3 +20,25 @@ export enum PhoneEvents {
SET_TIME = 'npwd:setGameTime',
SEND_CREDENTIALS = 'npwd:sendCredentials',
}
+
+// Used to standardize the server response
+export enum ErrorStringKeys {
+ SERVER_ERROR = 'GENERAL_SERVER_ERROR',
+ DELETE_FAILED = 'DELETE_FAILED',
+ ADD_FAILED = 'ADD_FAILED',
+ UPDATE_FAILED = 'UPDATED_FAILED',
+ FETCH_FAILED = 'FETCH_FAILED',
+}
+
+export interface FxServerRespError {
+ errorCode: ErrorStringKeys;
+ message: string;
+}
+
+export interface FxServerResponse {
+ data?: unknown;
+ action: string;
+ status: 'success' | 'failure';
+ app: string;
+ error?: FxServerRespError;
+}
diff --git a/yarn.lock b/yarn.lock
index d4b2d91..b40b9eb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -23,6 +23,144 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
+"@commitlint/cli@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-12.1.1.tgz#740370e557a8a17f415052821cdd5276ecb0ab98"
+ integrity sha512-SB67/s6VJ50seoPx/Sr2gj1fMzKrx+udgarecGdr8h43ah+M2e22gjQJ7xHv5KwyPQ+6ug1YOMCL34ubT4zupQ==
+ dependencies:
+ "@commitlint/format" "^12.1.1"
+ "@commitlint/lint" "^12.1.1"
+ "@commitlint/load" "^12.1.1"
+ "@commitlint/read" "^12.1.1"
+ "@commitlint/types" "^12.1.1"
+ get-stdin "8.0.0"
+ lodash "^4.17.19"
+ resolve-from "5.0.0"
+ resolve-global "1.0.0"
+ yargs "^16.2.0"
+
+"@commitlint/config-conventional@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-12.1.1.tgz#73dd3b1a7912138420d248f334f15c94c250bc9e"
+ integrity sha512-15CqbXMsQiEb0qbzjEHe2OkzaXPYSp7RxaS6KoSVk/4W0QiigquavQ+M0huBZze92h0lMS6Pxoq4AJ5CQ3D+iQ==
+ dependencies:
+ conventional-changelog-conventionalcommits "^4.3.1"
+
+"@commitlint/ensure@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/ensure/-/ensure-12.1.1.tgz#bcefc85f7f8a41bb31f67d7a8966e322b47a6e43"
+ integrity sha512-XEUQvUjzBVQM7Uv8vYz+c7PDukFvx0AvQEyX/V+PaTkCK/xPvexu7FLbFwvypjSt9BPMf+T/rhB1hVmldkd6lw==
+ dependencies:
+ "@commitlint/types" "^12.1.1"
+ lodash "^4.17.19"
+
+"@commitlint/execute-rule@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/execute-rule/-/execute-rule-12.1.1.tgz#8aad1d46fb78b3199e4ae36debdc93570bf765ea"
+ integrity sha512-6mplMGvLCKF5LieL7BRhydpg32tm6LICnWQADrWU4S5g9PKi2utNvhiaiuNPoHUXr29RdbNaGNcyyPv8DSjJsQ==
+
+"@commitlint/format@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/format/-/format-12.1.1.tgz#a6b14f8605171374eecc2c463098d63c127ab7df"
+ integrity sha512-bTAoOryTFLqls17JTaRwk2WDVOP0NwuG4F/JPK8RaF6DMZNVQTfajkgTxFENNZRnESfau1BvivvEXfUAW2ZsvA==
+ dependencies:
+ "@commitlint/types" "^12.1.1"
+ chalk "^4.0.0"
+
+"@commitlint/is-ignored@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/is-ignored/-/is-ignored-12.1.1.tgz#6075a5cd2dcda7b6ec93322f5dbe2142cfbb3248"
+ integrity sha512-Sn4fsnWX+wLAJOD/UZeoVruB98te1TyPYRiDEq0MhRJAQIrP+7jE/O3/ass68AAMq00HvH3OK9kt4UBXggcGjA==
+ dependencies:
+ "@commitlint/types" "^12.1.1"
+ semver "7.3.5"
+
+"@commitlint/lint@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/lint/-/lint-12.1.1.tgz#cdd898af6eadba8f9e71d7f1255b5a479a757078"
+ integrity sha512-FFFPpku/E0svL1jaUVqosuZJDDWiNWYBlUw5ZEljh3MwWRcoaWtMIX5bseX+IvHpFZsCTAiBs1kCgNulCi0UvA==
+ dependencies:
+ "@commitlint/is-ignored" "^12.1.1"
+ "@commitlint/parse" "^12.1.1"
+ "@commitlint/rules" "^12.1.1"
+ "@commitlint/types" "^12.1.1"
+
+"@commitlint/load@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/load/-/load-12.1.1.tgz#5a7fb8be11e520931d1237c5e8dc401b7cc9c6c1"
+ integrity sha512-qOQtgNdJRULUQWP9jkpTwhj7aEtnqUtqeUpbQ9rjS+GIUST65HZbteNUX4S0mAEGPWqy2aK5xGd73cUfFSvuuw==
+ dependencies:
+ "@commitlint/execute-rule" "^12.1.1"
+ "@commitlint/resolve-extends" "^12.1.1"
+ "@commitlint/types" "^12.1.1"
+ chalk "^4.0.0"
+ cosmiconfig "^7.0.0"
+ lodash "^4.17.19"
+ resolve-from "^5.0.0"
+
+"@commitlint/message@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/message/-/message-12.1.1.tgz#56eb1dbb561e85e9295380a46ff3b09bc93cac65"
+ integrity sha512-RakDSLAiOligXjhbLahV8HowF4K75pZIcs0+Ii9Q8Gz5H3DWf1Ngit7alFTWfcbf/+DTjSzVPov5HiwQZPIBUg==
+
+"@commitlint/parse@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/parse/-/parse-12.1.1.tgz#3e49d6dc113d59cf266af0db99e320e933108c56"
+ integrity sha512-nuljIvAbBDr93DgL0wCArftEIhjSghawAwhvrKNV9FFcqAJqfVqitwMxJrNDCQ5pgUMCSKULLOEv+dA0bLlTEQ==
+ dependencies:
+ "@commitlint/types" "^12.1.1"
+ conventional-changelog-angular "^5.0.11"
+ conventional-commits-parser "^3.0.0"
+
+"@commitlint/read@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/read/-/read-12.1.1.tgz#22a2d7fd1eab5e38b9b262311af28ac42f9a5097"
+ integrity sha512-1k0CQEoZIdixvmqZRKEcWdj2XiKS7SlizEOJ1SE99Qui5d5FlBey8eaooTGgmpR6zObpIHJehtEPzM3VzUT3qA==
+ dependencies:
+ "@commitlint/top-level" "^12.1.1"
+ "@commitlint/types" "^12.1.1"
+ fs-extra "^9.0.0"
+ git-raw-commits "^2.0.0"
+
+"@commitlint/resolve-extends@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/resolve-extends/-/resolve-extends-12.1.1.tgz#80a78b0940775d17888dd2985b52f93d93e0a885"
+ integrity sha512-/DXRt0S0U3o9lq5cc8OL1Lkx0IjW0HcDWjUkUXshAajBIKBYSJB8x/loNCi1krNEJ8SwLXUEFt5OLxNO6wE9yQ==
+ dependencies:
+ import-fresh "^3.0.0"
+ lodash "^4.17.19"
+ resolve-from "^5.0.0"
+ resolve-global "^1.0.0"
+
+"@commitlint/rules@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/rules/-/rules-12.1.1.tgz#d59182a837d2addf301a3a4ef83316ae7e70248f"
+ integrity sha512-oCcLF/ykcJfhM2DeeaDyrgdaiuKsqIPNocugdPj2WEyhSYqmx1/u18CV96LAtW+WyyiOLCCeiZwiQutx3T5nXg==
+ dependencies:
+ "@commitlint/ensure" "^12.1.1"
+ "@commitlint/message" "^12.1.1"
+ "@commitlint/to-lines" "^12.1.1"
+ "@commitlint/types" "^12.1.1"
+
+"@commitlint/to-lines@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/to-lines/-/to-lines-12.1.1.tgz#40fbed1767d637249ce49b311a51909d8361ecf8"
+ integrity sha512-W23AH2XF5rI27MOAPSSr0TUDoRe7ZbFoRtYhFnPu2MBmcuDA9Tmfd9N5sM2tBXtdE26uq3SazwKqGt1OoGAilQ==
+
+"@commitlint/top-level@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/top-level/-/top-level-12.1.1.tgz#228df8fc36b6d7ea7ad149badfb6ef53dbc7001d"
+ integrity sha512-g7uRbr81QEIg+pbii0OkE17Zh/2C/f6dSmiMDVRn1S0+hNHR1bENCh18hVUKcV/qKTUsKkFlhhWXM9mQBfxQJw==
+ dependencies:
+ find-up "^5.0.0"
+
+"@commitlint/types@^12.1.1":
+ version "12.1.1"
+ resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-12.1.1.tgz#8e651f6af0171cd4f8d464c6c37a7cf63ee071bd"
+ integrity sha512-+qGH+s2Lo6qwacV2X3/ZypZwaAI84ift+1HBjXdXtI/q0F5NtmXucV3lcQOTviMTNiJhq4qWON2fjci2NItASw==
+ dependencies:
+ chalk "^4.0.0"
+
"@evocateur/libnpmaccess@^3.1.2":
version "3.1.2"
resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845"
@@ -802,6 +940,26 @@
dependencies:
"@octokit/types" "^6.0.0"
+"@octokit/auth-token@^2.4.4":
+ version "2.4.5"
+ resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.5.tgz#568ccfb8cb46f36441fac094ce34f7a875b197f3"
+ integrity sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==
+ dependencies:
+ "@octokit/types" "^6.0.3"
+
+"@octokit/core@^3.4.0":
+ version "3.4.0"
+ resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.4.0.tgz#b48aa27d755b339fe7550548b340dcc2b513b742"
+ integrity sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==
+ dependencies:
+ "@octokit/auth-token" "^2.4.4"
+ "@octokit/graphql" "^4.5.8"
+ "@octokit/request" "^5.4.12"
+ "@octokit/request-error" "^2.0.5"
+ "@octokit/types" "^6.0.3"
+ before-after-hook "^2.2.0"
+ universal-user-agent "^6.0.0"
+
"@octokit/endpoint@^6.0.1":
version "6.0.10"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.10.tgz#741ce1fa2f4fb77ce8ebe0c6eaf5ce63f565f8e8"
@@ -811,11 +969,25 @@
is-plain-object "^5.0.0"
universal-user-agent "^6.0.0"
+"@octokit/graphql@^4.5.8":
+ version "4.6.1"
+ resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.6.1.tgz#f975486a46c94b7dbe58a0ca751935edc7e32cc9"
+ integrity sha512-2lYlvf4YTDgZCTXTW4+OX+9WTLFtEUc6hGm4qM1nlZjzxj+arizM4aHWzBVBCxY9glh7GIs0WEuiSgbVzv8cmA==
+ dependencies:
+ "@octokit/request" "^5.3.0"
+ "@octokit/types" "^6.0.3"
+ universal-user-agent "^6.0.0"
+
"@octokit/openapi-types@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-2.3.0.tgz#075c4e5a1d05d0b62cd8048b71764537aa870c00"
integrity sha512-Own8lHWVi5eEfLOnsIzAx16BoRbpkzac3QDUCxIqYMf4bjz+AGpv17UfRn1Va4lVmjwOpvZglpFI3mmxuQ+sIQ==
+"@octokit/openapi-types@^7.0.0":
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-7.0.0.tgz#0f6992db9854af15eca77d71ab0ec7fad2f20411"
+ integrity sha512-gV/8DJhAL/04zjTI95a7FhQwS6jlEE0W/7xeYAzuArD0KVAVWDLP2f3vi98hs3HLTczxXdRK/mF0tRoQPpolEw==
+
"@octokit/plugin-enterprise-rest@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-6.0.1.tgz#e07896739618dab8da7d4077c658003775f95437"
@@ -859,6 +1031,15 @@
deprecation "^2.0.0"
once "^1.4.0"
+"@octokit/request-error@^2.0.5":
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.5.tgz#72cc91edc870281ad583a42619256b380c600143"
+ integrity sha512-T/2wcCFyM7SkXzNoyVNWjyVlUwBvW3igM3Btr/eKYiPmucXTtkxt2RBsf6gn3LTzaLSLTQtNmvg+dGsOxQrjZg==
+ dependencies:
+ "@octokit/types" "^6.0.3"
+ deprecation "^2.0.0"
+ once "^1.4.0"
+
"@octokit/request@^5.2.0":
version "5.4.12"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.12.tgz#b04826fa934670c56b135a81447be2c1723a2ffc"
@@ -873,6 +1054,18 @@
once "^1.4.0"
universal-user-agent "^6.0.0"
+"@octokit/request@^5.3.0", "@octokit/request@^5.4.12":
+ version "5.4.15"
+ resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.15.tgz#829da413dc7dd3aa5e2cdbb1c7d0ebe1f146a128"
+ integrity sha512-6UnZfZzLwNhdLRreOtTkT9n57ZwulCve8q3IT/Z477vThu6snfdkBuhxnChpOKNGxcQ71ow561Qoa6uqLdPtag==
+ dependencies:
+ "@octokit/endpoint" "^6.0.1"
+ "@octokit/request-error" "^2.0.0"
+ "@octokit/types" "^6.7.1"
+ is-plain-object "^5.0.0"
+ node-fetch "^2.6.1"
+ universal-user-agent "^6.0.0"
+
"@octokit/rest@^16.28.4":
version "16.43.2"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.2.tgz#c53426f1e1d1044dee967023e3279c50993dd91b"
@@ -910,6 +1103,13 @@
"@octokit/openapi-types" "^2.3.0"
"@types/node" ">= 8"
+"@octokit/types@^6.7.1":
+ version "6.14.2"
+ resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.14.2.tgz#64c9457f38fb8522bdbba3c8cc814590a2d61bf5"
+ integrity sha512-wiQtW9ZSy4OvgQ09iQOdyXYNN60GqjCL/UdMsepDr1Gr0QzpW6irIKbH3REuAHXAhxkEk9/F2a3Gcs1P6kW5jA==
+ dependencies:
+ "@octokit/openapi-types" "^7.0.0"
+
"@types/glob@^7.1.1":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
@@ -938,6 +1138,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
+"@types/parse-json@^4.0.0":
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
+ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
+
"@zkochan/cmd-shim@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e"
@@ -1011,6 +1216,11 @@ ansi-regex@^4.1.0:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
+ansi-regex@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
+ integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
+
ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
@@ -1018,7 +1228,7 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"
-ansi-styles@^4.1.0:
+ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
@@ -1149,6 +1359,11 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
+at-least-node@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
+ integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
+
atob-lite@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696"
@@ -1199,6 +1414,11 @@ before-after-hook@^2.0.0:
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"
integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==
+before-after-hook@^2.2.0:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.1.tgz#73540563558687586b52ed217dad6a802ab1549c"
+ integrity sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==
+
bluebird@^3.5.1, bluebird@^3.5.3, bluebird@^3.5.5:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
@@ -1321,6 +1541,11 @@ callsites@^2.0.0:
resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50"
integrity sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=
+callsites@^3.0.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
+ integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
+
camelcase-keys@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7"
@@ -1384,6 +1609,14 @@ chalk@^3.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
+chalk@^4.0.0:
+ version "4.1.1"
+ resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad"
+ integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==
+ dependencies:
+ ansi-styles "^4.1.0"
+ supports-color "^7.1.0"
+
chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
@@ -1430,6 +1663,15 @@ cliui@^5.0.0:
strip-ansi "^5.2.0"
wrap-ansi "^5.1.0"
+cliui@^7.0.2:
+ version "7.0.4"
+ resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
+ integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
+ dependencies:
+ string-width "^4.2.0"
+ strip-ansi "^6.0.0"
+ wrap-ansi "^7.0.0"
+
clone-deep@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
@@ -1547,7 +1789,7 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0:
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=
-conventional-changelog-angular@^5.0.3:
+conventional-changelog-angular@^5.0.11, conventional-changelog-angular@^5.0.3:
version "5.0.12"
resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-5.0.12.tgz#c979b8b921cbfe26402eb3da5bbfda02d865a2b9"
integrity sha512-5GLsbnkR/7A89RyHLvvoExbiGbd9xKdKqDTrArnPbOqBqG/2wIosu0fHwpeIRI8Tl94MhVNBXcLJZl92ZQ5USw==
@@ -1555,6 +1797,15 @@ conventional-changelog-angular@^5.0.3:
compare-func "^2.0.0"
q "^1.5.1"
+conventional-changelog-conventionalcommits@^4.3.1:
+ version "4.6.0"
+ resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.0.tgz#7fc17211dbca160acf24687bd2fdd5fd767750eb"
+ integrity sha512-sj9tj3z5cnHaSJCYObA9nISf7eq/YjscLPoq6nmew4SiOjxqL2KRpK20fjnjVbpNDjJ2HR3MoVcWKXwbVvzS0A==
+ dependencies:
+ compare-func "^2.0.0"
+ lodash "^4.17.15"
+ q "^1.5.1"
+
conventional-changelog-core@^3.1.6:
version "3.2.3"
resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-3.2.3.tgz#b31410856f431c847086a7dcb4d2ca184a7d88fb"
@@ -1603,6 +1854,19 @@ conventional-commits-filter@^2.0.2, conventional-commits-filter@^2.0.7:
lodash.ismatch "^4.4.0"
modify-values "^1.0.0"
+conventional-commits-parser@^3.0.0:
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.2.1.tgz#ba44f0b3b6588da2ee9fd8da508ebff50d116ce2"
+ integrity sha512-OG9kQtmMZBJD/32NEw5IhN5+HnBqVjy03eC+I71I0oQRFA5rOgA4OtPOYG7mz1GkCfCNxn3gKIX8EiHJYuf1cA==
+ dependencies:
+ JSONStream "^1.0.4"
+ is-text-path "^1.0.1"
+ lodash "^4.17.15"
+ meow "^8.0.0"
+ split2 "^3.0.0"
+ through2 "^4.0.0"
+ trim-off-newlines "^1.0.0"
+
conventional-commits-parser@^3.0.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.2.0.tgz#9e261b139ca4b7b29bcebbc54460da36894004ca"
@@ -1662,6 +1926,17 @@ cosmiconfig@^5.1.0:
js-yaml "^3.13.1"
parse-json "^4.0.0"
+cosmiconfig@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
+ integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==
+ dependencies:
+ "@types/parse-json" "^4.0.0"
+ import-fresh "^3.2.1"
+ parse-json "^5.0.0"
+ path-type "^4.0.0"
+ yaml "^1.10.0"
+
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@@ -1701,6 +1976,11 @@ dargs@^4.0.1:
dependencies:
number-is-nan "^1.0.0"
+dargs@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"
+ integrity sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==
+
dashdash@^1.12.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
@@ -1875,6 +2155,11 @@ emoji-regex@^7.0.1:
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==
+emoji-regex@^8.0.0:
+ version "8.0.0"
+ resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
+ integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
+
encoding@^0.1.11:
version "0.1.13"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
@@ -1950,6 +2235,11 @@ es6-promisify@^5.0.0:
dependencies:
es6-promise "^4.0.3"
+escalade@^3.1.1:
+ version "3.1.1"
+ resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
+ integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
+
escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -2133,6 +2423,14 @@ find-up@^4.1.0:
locate-path "^5.0.0"
path-exists "^4.0.0"
+find-up@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"
+ integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
+ dependencies:
+ locate-path "^6.0.0"
+ path-exists "^4.0.0"
+
flush-write-stream@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"
@@ -2184,6 +2482,16 @@ fs-extra@^8.1.0:
jsonfile "^4.0.0"
universalify "^0.1.0"
+fs-extra@^9.0.0:
+ version "9.1.0"
+ resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
+ integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
+ dependencies:
+ at-least-node "^1.0.0"
+ graceful-fs "^4.2.0"
+ jsonfile "^6.0.1"
+ universalify "^2.0.0"
+
fs-minipass@^1.2.5:
version "1.2.7"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7"
@@ -2230,7 +2538,7 @@ genfun@^5.0.0:
resolved "https://registry.yarnpkg.com/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537"
integrity sha512-KGDOARWVga7+rnB3z9Sd2Letx515owfk0hSxHGuqjANb1M+x2bGZGqHLiozPsYMdM2OubeMni/Hpwmjq6qIUhA==
-get-caller-file@^2.0.1:
+get-caller-file@^2.0.1, get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
@@ -2260,6 +2568,11 @@ get-port@^4.2.0:
resolved "https://registry.yarnpkg.com/get-port/-/get-port-4.2.0.tgz#e37368b1e863b7629c43c5a323625f95cf24b119"
integrity sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw==
+get-stdin@8.0.0:
+ version "8.0.0"
+ resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53"
+ integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==
+
get-stdin@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
@@ -2302,6 +2615,17 @@ git-raw-commits@2.0.0:
split2 "^2.0.0"
through2 "^2.0.0"
+git-raw-commits@^2.0.0:
+ version "2.0.10"
+ resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.10.tgz#e2255ed9563b1c9c3ea6bd05806410290297bbc1"
+ integrity sha512-sHhX5lsbG9SOO6yXdlwgEMQ/ljIn7qMpAbJZCGfXX2fq5T8M5SrDnpYk9/4HswTildcIqatsWa91vty6VhWSaQ==
+ dependencies:
+ dargs "^7.0.0"
+ lodash "^4.17.15"
+ meow "^8.0.0"
+ split2 "^3.0.0"
+ through2 "^4.0.0"
+
git-remote-origin-url@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f"
@@ -2372,6 +2696,13 @@ glob@^7.1.1, glob@^7.1.3, glob@^7.1.4:
once "^1.3.0"
path-is-absolute "^1.0.0"
+global-dirs@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445"
+ integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=
+ dependencies:
+ ini "^1.3.4"
+
globby@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d"
@@ -2392,9 +2723,9 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
handlebars@^4.7.6:
- version "4.7.6"
- resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
- integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
+ version "4.7.7"
+ resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1"
+ integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.0"
@@ -2480,9 +2811,9 @@ has@^1.0.3:
function-bind "^1.1.1"
hosted-git-info@^2.1.4, hosted-git-info@^2.7.1:
- version "2.8.8"
- resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
- integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
+ version "2.8.9"
+ resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
+ integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
hosted-git-info@^3.0.6:
version "3.0.7"
@@ -2582,6 +2913,14 @@ import-fresh@^2.0.0:
caller-path "^2.0.0"
resolve-from "^3.0.0"
+import-fresh@^3.0.0, import-fresh@^3.2.1:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
+ integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==
+ dependencies:
+ parent-module "^1.0.0"
+ resolve-from "^4.0.0"
+
import-local@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d"
@@ -2792,6 +3131,11 @@ is-fullwidth-code-point@^2.0.0:
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
+is-fullwidth-code-point@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
+ integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
+
is-glob@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
@@ -2975,6 +3319,15 @@ jsonfile@^4.0.0:
optionalDependencies:
graceful-fs "^4.1.6"
+jsonfile@^6.0.1:
+ version "6.1.0"
+ resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
+ integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
+ dependencies:
+ universalify "^2.0.0"
+ optionalDependencies:
+ graceful-fs "^4.1.6"
+
jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
@@ -3098,6 +3451,13 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"
+locate-path@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
+ integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
+ dependencies:
+ p-locate "^5.0.0"
+
lodash._reinterpolate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -3153,6 +3513,11 @@ lodash@^4.17.12, lodash@^4.17.15, lodash@^4.2.1:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
+lodash@^4.17.19:
+ version "4.17.21"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
+ integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
+
loud-rejection@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
@@ -3809,6 +4174,13 @@ p-limit@^2.0.0, p-limit@^2.2.0:
dependencies:
p-try "^2.0.0"
+p-limit@^3.0.2:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
+ integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
+ dependencies:
+ yocto-queue "^0.1.0"
+
p-locate@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
@@ -3830,6 +4202,13 @@ p-locate@^4.1.0:
dependencies:
p-limit "^2.2.0"
+p-locate@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
+ integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
+ dependencies:
+ p-limit "^3.0.2"
+
p-map-series@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-map-series/-/p-map-series-1.0.0.tgz#bf98fe575705658a9e1351befb85ae4c1f07bdca"
@@ -3885,6 +4264,13 @@ parallel-transform@^1.1.0:
inherits "^2.0.3"
readable-stream "^2.1.5"
+parent-module@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
+ integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
+ dependencies:
+ callsites "^3.0.0"
+
parse-github-repo-url@^1.3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50"
@@ -3998,6 +4384,11 @@ path-type@^3.0.0:
dependencies:
pify "^3.0.0"
+path-type@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
+ integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
+
performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@@ -4269,7 +4660,7 @@ read@1, read@~1.0.1:
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
-"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.0.2:
+"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==
@@ -4380,6 +4771,11 @@ resolve-cwd@^2.0.0:
dependencies:
resolve-from "^3.0.0"
+resolve-from@5.0.0, resolve-from@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
+ integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
+
resolve-from@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
@@ -4390,6 +4786,13 @@ resolve-from@^4.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
+resolve-global@1.0.0, resolve-global@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/resolve-global/-/resolve-global-1.0.0.tgz#a2a79df4af2ca3f49bf77ef9ddacd322dad19255"
+ integrity sha512-zFa12V4OLtT5XUX/Q4VLvTfBf+Ok0SPc1FNGM/z9ctUdiU618qwKpWnd0CHs3+RqROfyEg/DhuHbMWYqcgljEw==
+ dependencies:
+ global-dirs "^0.1.1"
+
resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
@@ -4474,6 +4877,13 @@ safe-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
+semver@7.3.5:
+ version "7.3.5"
+ resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
+ integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
+ dependencies:
+ lru-cache "^6.0.0"
+
semver@^6.0.0, semver@^6.2.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
@@ -4676,6 +5086,13 @@ split2@^2.0.0:
dependencies:
through2 "^2.0.2"
+split2@^3.0.0:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f"
+ integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==
+ dependencies:
+ readable-stream "^3.0.0"
+
split@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9"
@@ -4704,9 +5121,9 @@ sshpk@^1.7.0:
tweetnacl "~0.14.0"
ssri@^6.0.0, ssri@^6.0.1:
- version "6.0.1"
- resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
- integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
+ integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==
dependencies:
figgy-pudding "^3.5.1"
@@ -4762,6 +5179,15 @@ string-width@^3.0.0, string-width@^3.1.0:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"
+string-width@^4.1.0, string-width@^4.2.0:
+ version "4.2.2"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
+ integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
+ dependencies:
+ emoji-regex "^8.0.0"
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.0"
+
string.prototype.trimend@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz#a22bd53cca5c7cf44d7c9d5c732118873d6cd18b"
@@ -4813,6 +5239,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"
+strip-ansi@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
+ integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
+ dependencies:
+ ansi-regex "^5.0.0"
+
strip-bom@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e"
@@ -5064,9 +5497,9 @@ typedarray@^0.0.6:
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
uglify-js@^3.1.4:
- version "3.12.4"
- resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.12.4.tgz#93de48bb76bb3ec0fc36563f871ba46e2ee5c7ee"
- integrity sha512-L5i5jg/SHkEqzN18gQMTWsZk3KelRsfD1wUVNqtq0kzqWQqcJjyL8yc1o8hJgRrWqrAl2mUFbhfznEIoi7zi2A==
+ version "3.13.5"
+ resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.13.5.tgz#5d71d6dbba64cf441f32929b1efce7365bb4f113"
+ integrity sha512-xtB8yEqIkn7zmOyS2zUNBsYCBRhDkvlNxMMY2smuJ/qA8NCHeQvKCF3i9Z4k8FJH4+PJvZRtMrPynfZ75+CSZw==
uid-number@0.0.6:
version "0.0.6"
@@ -5119,6 +5552,11 @@ universalify@^0.1.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
+universalify@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
+ integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
+
unset-value@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
@@ -5258,6 +5696,15 @@ wrap-ansi@^5.1.0:
string-width "^3.0.0"
strip-ansi "^5.0.0"
+wrap-ansi@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
+ integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
+ dependencies:
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
@@ -5314,6 +5761,11 @@ y18n@^4.0.0:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
+y18n@^5.0.5:
+ version "5.0.8"
+ resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
+ integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
+
yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
@@ -5324,6 +5776,11 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
+yaml@^1.10.0:
+ version "1.10.2"
+ resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
+ integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
+
yargs-parser@^15.0.1:
version "15.0.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.1.tgz#54786af40b820dcb2fb8025b11b4d659d76323b3"
@@ -5332,6 +5789,11 @@ yargs-parser@^15.0.1:
camelcase "^5.0.0"
decamelize "^1.2.0"
+yargs-parser@^20.2.2:
+ version "20.2.7"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
+ integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==
+
yargs-parser@^20.2.3:
version "20.2.4"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
@@ -5353,3 +5815,21 @@ yargs@^14.2.2:
which-module "^2.0.0"
y18n "^4.0.0"
yargs-parser "^15.0.1"
+
+yargs@^16.2.0:
+ version "16.2.0"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
+ integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
+ dependencies:
+ cliui "^7.0.2"
+ escalade "^3.1.1"
+ get-caller-file "^2.0.5"
+ require-directory "^2.1.1"
+ string-width "^4.2.0"
+ y18n "^5.0.5"
+ yargs-parser "^20.2.2"
+
+yocto-queue@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
+ integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==