mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
refactor(events): Events are now tied to a common enum typings (#167)
* chore(scripts/twitter): Refactored twitter to use event enums * chore(scripts/marketplace): Refactored marketplace to use event enums * chore(scripts/messages): Refactored messages to use event enums * chore(scripts/contacts): Refactored contacts to use event enums * chore(scripts/calls): Refactored calls to use event enums * chore(scripts/notes): Refactored notes to use event enums * chore(scripts/photos): Refactored photos to use event enums * chore(scripts/bank): Refactored bank to use event enums * chore(scripts/phone): Refactored phone to use event enums * chore(events): Removed old events object * refactor(phone/nui-events): Attached NUI events to respective enum * tweak(event-enums): Added npwd prefix to all events * tweak(phone/serve): Added craco to override CRA without eject Also bumped react-scripts to 4.0.1, with seemingly no issues * fix(typings/twitter): Fixed method enums for twitter
This commit is contained in:
62 files changed
+4734
-3470
No files matched your search
@@ -3,6 +3,8 @@
|
||||
|
||||
resources/html
|
||||
|
||||
phone/.eslintcache
|
||||
|
||||
# Node Modules and Built Folders
|
||||
node_modules
|
||||
build
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const {
|
||||
addAfterLoader,
|
||||
removeLoaders,
|
||||
loaderByName,
|
||||
getLoaders,
|
||||
throwUnexpectedConfigError,
|
||||
} = require('@craco/craco');
|
||||
|
||||
const throwError = (message) =>
|
||||
throwUnexpectedConfigError({
|
||||
packageName: 'craco',
|
||||
githubRepo: 'gsoft-inc/craco',
|
||||
message,
|
||||
githubIssueQuery: 'webpack',
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
webpack: {
|
||||
configure: (webpackConfig, { paths }) => {
|
||||
const { hasFoundAny, matches } = getLoaders(webpackConfig, loaderByName('babel-loader'));
|
||||
if (!hasFoundAny) throwError('failed to find babel-loader');
|
||||
|
||||
const { hasRemovedAny, removedCount } = removeLoaders(
|
||||
webpackConfig,
|
||||
loaderByName('babel-loader'),
|
||||
);
|
||||
if (!hasRemovedAny) throwError('no babel-loader to remove');
|
||||
if (removedCount !== 2) throwError('had expected to remove 2 babel loader instances');
|
||||
webpackConfig.resolve.plugins = webpackConfig.resolve.plugins.filter(
|
||||
({ constructor: c }) => !c || c.name !== 'ModuleScopePlugin',
|
||||
);
|
||||
|
||||
const tsLoader = {
|
||||
test: /\.tsx?$/,
|
||||
loader: require.resolve('ts-loader'),
|
||||
options: { transpileOnly: true },
|
||||
};
|
||||
|
||||
const { isAdded: tsLoaderIsAdded } = addAfterLoader(
|
||||
webpackConfig,
|
||||
loaderByName('url-loader'),
|
||||
tsLoader,
|
||||
);
|
||||
|
||||
if (!tsLoaderIsAdded) throwError('failed to add ts-loader');
|
||||
|
||||
const { isAdded: babelLoaderIsAdded } = addAfterLoader(
|
||||
webpackConfig,
|
||||
loaderByName('ts-loader'),
|
||||
matches[1].loader, // babel-loader
|
||||
);
|
||||
|
||||
if (!babelLoaderIsAdded) throwError('failed to add back babel-loader for non-application JS');
|
||||
|
||||
return webpackConfig;
|
||||
},
|
||||
},
|
||||
};
|
||||
+5
-3
@@ -33,7 +33,7 @@
|
||||
"react-i18next": "^11.7.1",
|
||||
"react-popper": "^2.2.3",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "3.4.3",
|
||||
"react-scripts": "4.0.1",
|
||||
"recoil": "^0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -43,6 +43,7 @@
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@craco/craco": "^6.1.1",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
@@ -63,6 +64,7 @@
|
||||
"cra-build-watch": "^3.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"css-loader": "^2.1.1",
|
||||
"customize-cra": "^1.0.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"html-loader": "^0.5.5",
|
||||
"html-webpack-plugin": "^4.3.0",
|
||||
@@ -79,11 +81,11 @@
|
||||
"scripts": {
|
||||
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
|
||||
"copy:config": "cp-cli ../config.json ./src/config.autogen.json",
|
||||
"start": "yarn copy:config && react-scripts start",
|
||||
"start": "craco start",
|
||||
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
|
||||
"build": "yarn copy:config && cross-env NODE_ENV=production webpack --config webpack/prod.config.js --color -p --progress --hide-modules --display-optimization-bailout",
|
||||
"build:dev": "cross-env NODE_ENV=development webpack --config webpack/dev.config.js --color -p --progress --hide-modules --display-optimization-bailout --analyze",
|
||||
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"test": "craco test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Button, List, ListItem, TextField, makeStyles } from '@material-ui/core
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
import { useBankModal } from '../../hooks/useBankModal';
|
||||
import { BankEvents } from '../../../../../../typings/bank';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
@@ -43,7 +44,7 @@ export const TransferModal = () => {
|
||||
|
||||
const addTransfer = () => {
|
||||
const transferAmount = parseInt(amount);
|
||||
Nui.send('phone:addTransfer', {
|
||||
Nui.send(BankEvents.ADD_TRANSFER, {
|
||||
targetID,
|
||||
transferAmount,
|
||||
message,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
|
||||
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
|
||||
import { PhotoEvents } from '../../../../../../typings/photo';
|
||||
|
||||
export const GalleryGrid = () => {
|
||||
const classes = useStyles();
|
||||
@@ -19,7 +20,7 @@ export const GalleryGrid = () => {
|
||||
const photos = usePhotos();
|
||||
|
||||
const handleCamera = () => {
|
||||
Nui.send('phone:TakePhoto', {});
|
||||
Nui.send(PhotoEvents.TAKE_PHOTO, {});
|
||||
};
|
||||
|
||||
const handlePhotoOpen = (photo) => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { ICameraPhoto } from '../../hooks/usePhotos';
|
||||
import { ShareModal } from './ShareModal';
|
||||
import { PhotoEvents } from '../../../../../../typings/photo';
|
||||
|
||||
export const GalleryModal = () => {
|
||||
const classes = useStyles();
|
||||
@@ -28,7 +29,7 @@ export const GalleryModal = () => {
|
||||
};
|
||||
|
||||
const handleDeletePhoto = () => {
|
||||
Nui.send('photo:deletePhoto', {
|
||||
Nui.send(PhotoEvents.DELETE_PHOTO, {
|
||||
image: meta.image,
|
||||
});
|
||||
history.push(referal);
|
||||
|
||||
@@ -10,6 +10,7 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { SearchContacts } from './SearchContacts';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { CallEvents } from '../../../../../../typings/call';
|
||||
|
||||
export const ContactList = () => {
|
||||
const { filteredContacts } = useFilteredContacts();
|
||||
@@ -27,7 +28,7 @@ export const ContactList = () => {
|
||||
level: 2,
|
||||
data: true,
|
||||
});
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { ContactEvents } from '../../../../../../typings/contact';
|
||||
|
||||
interface ContactInfoRouteParams {
|
||||
mode: string;
|
||||
@@ -79,7 +80,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:addContacts', {
|
||||
Nui.send(ContactEvents.ADD_CONTACT, {
|
||||
display: name,
|
||||
number,
|
||||
avatar,
|
||||
@@ -93,7 +94,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:updateContact', {
|
||||
Nui.send(ContactEvents.UPDATE_CONTACT, {
|
||||
id: contact.id,
|
||||
display: name,
|
||||
number,
|
||||
@@ -108,7 +109,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:deleteContact', {
|
||||
Nui.send(ContactEvents.DELETE_CONTACT, {
|
||||
id: contact.id,
|
||||
});
|
||||
history.goBack();
|
||||
|
||||
@@ -6,6 +6,7 @@ import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { DialInputCtx, IDialInputCtx } from '../context/InputContext';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
@@ -33,7 +34,7 @@ export const DialerInput = () => {
|
||||
const { inputVal, set } = useContext<IDialInputCtx>(DialInputCtx);
|
||||
|
||||
const handleCall = (number: string) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ListItem } from '../../../../ui/components/ListItem';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { ICall } from '../../../../../../typings/call';
|
||||
import { CallEvents, ICall } from '../../../../../../typings/call';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
@@ -35,7 +35,7 @@ export const DialerHistory = ({ calls }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleCall = (phoneNumber) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number: phoneNumber,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -11,13 +11,14 @@ import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import NewMessageGroupButton from './form/NewMessageGroupButton';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
|
||||
import { MessageEvents } from '../../../../../typings/messages';
|
||||
|
||||
export const MessagesApp = () => {
|
||||
const messages = useApp('MESSAGES');
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
Nui.send('phone:fetchMessageGroups');
|
||||
Nui.send(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Paper, Box, makeStyles, TextField, Button } from '@material-ui/core';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
import ImageIcon from '@material-ui/icons/Image';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
interface IProps {
|
||||
onAddImageClick(): void;
|
||||
@@ -25,7 +26,7 @@ const MessageInput = ({ messageGroupId, onAddImageClick }: IProps) => {
|
||||
if (message.trim()) {
|
||||
// don't allow the user to submit white space
|
||||
|
||||
Nui.send('phone:sendMessage', {
|
||||
Nui.send(MessageEvents.SEND_MESSAGE, {
|
||||
groupId: messageGroupId,
|
||||
message,
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { Contact } from '../../../../../../typings/contact';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const history = useHistory();
|
||||
@@ -32,7 +33,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const labelValue = isGroupChat ? label.trim() : null;
|
||||
|
||||
if (phoneNumbers.length) {
|
||||
Nui.send('phone:createMessageGroup', {
|
||||
Nui.send(MessageEvents.CREATE_MESSAGE_GROUP, {
|
||||
phoneNumbers,
|
||||
label: labelValue,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Box, List } from '@material-ui/core';
|
||||
import { MessageGroup } from '../../../../../../typings/messages';
|
||||
import { MessageEvents, MessageGroup } from '../../../../../../typings/messages';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import useMessages from '../../hooks/useMessages';
|
||||
import MessageGroupItem from './MessageGroupItem';
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { ContextMenu } from '../../../../ui/components/ContextMenu';
|
||||
import { deleteQueryFromLocation } from '../../../../common/utils/deleteQueryFromLocation';
|
||||
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
interface IProps {
|
||||
isOpen: boolean;
|
||||
@@ -34,7 +35,7 @@ export const MessageImageModal = ({ isOpen, messageGroupId, onClose, image }: IP
|
||||
|
||||
const sendImageMessage = useCallback(
|
||||
(m) => {
|
||||
Nui.send('phone:sendMessage', {
|
||||
Nui.send(MessageEvents.SEND_MESSAGE, {
|
||||
groupId: messageGroupId,
|
||||
message: m,
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import Modal from '../../../../ui/components/Modal';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
const LARGE_HEADER_CHARS = 30;
|
||||
const MAX_HEADER_CHARS = 80;
|
||||
@@ -92,7 +93,7 @@ export const MessageModal = () => {
|
||||
// sends all unread messages
|
||||
useEffect(() => {
|
||||
if (activeMessageGroup?.groupId && activeMessageGroup.unreadCount > 0) {
|
||||
Nui.send('phone:setReadMessages', {
|
||||
Nui.send(MessageEvents.SET_MESSAGE_READ, {
|
||||
groupId: activeMessageGroup.groupId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import Nui from '../../../os/nui-events/utils/Nui';
|
||||
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 classes = useStyles();
|
||||
@@ -31,14 +32,14 @@ export const NoteModal = () => {
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
Nui.send('phone:addNote', detail);
|
||||
Nui.send(NotesEvents.ADD_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
const id = detail.id;
|
||||
Nui.send('phone:deleteNote', {
|
||||
Nui.send(NotesEvents.DELETE_NOTE, {
|
||||
id,
|
||||
});
|
||||
setDetail(null);
|
||||
@@ -46,7 +47,7 @@ export const NoteModal = () => {
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send('phone:updateNote', detail);
|
||||
Nui.send(NotesEvents.UPDATE_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box, Tooltip, Button } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import React from 'react';
|
||||
import { MarketplaceListing } from '../../../../../../typings/marketplace';
|
||||
import { MarketplaceEvents, MarketplaceListing } from '../../../../../../typings/marketplace';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import ReportIcon from '@material-ui/icons/Report';
|
||||
@@ -10,6 +10,7 @@ import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router';
|
||||
import { CallEvents } from '../../../../../../typings/call';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
icon: {
|
||||
@@ -24,17 +25,17 @@ export const ListingActions = ({ listing }: { listing: MarketplaceListing }) =>
|
||||
const history = useHistory();
|
||||
|
||||
const handleDeleteListing = () => {
|
||||
Nui.send('phone:marketplaceDeleteListing', {
|
||||
Nui.send(MarketplaceEvents.DELETE_LISTING, {
|
||||
id: listing.id,
|
||||
});
|
||||
};
|
||||
|
||||
const handleReportListing = () => {
|
||||
Nui.send('phone:reportListing', listing);
|
||||
Nui.send(MarketplaceEvents.REPORT_LISTING, listing);
|
||||
};
|
||||
|
||||
const handleCall = () => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number: listing.number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { makeStyles, Button, TextField } from '@material-ui/core';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -34,7 +35,7 @@ export const ListingForm = () => {
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
const addListing = () => {
|
||||
Nui.send('phone:addListing', {
|
||||
Nui.send(MarketplaceEvents.ADD_LISTING, {
|
||||
title,
|
||||
url,
|
||||
description,
|
||||
|
||||
@@ -15,7 +15,7 @@ import ControlButtons from './buttons/ControlButtons';
|
||||
import IconButtons from './buttons/IconButtons';
|
||||
import { usePhone } from '../../../os/phone/hooks/usePhone';
|
||||
import { getNewLineCount } from '../utils/message';
|
||||
import { NewTweet } from '../../../../../typings/twitter';
|
||||
import { NewTweet, TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -110,7 +110,7 @@ export const AddTweetModal = () => {
|
||||
images:
|
||||
images && images.length > 0 ? images.map((image) => image.link).join(IMAGE_DELIMITER) : '',
|
||||
};
|
||||
Nui.send('phone:createTweet', data);
|
||||
Nui.send(TwitterEvents.CREATE_TWEET, data);
|
||||
_handleClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useProfile } from '../hooks/useProfile';
|
||||
import ProfilePrompt from './profile/ProfilePrompt';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import { TwitterThemeProvider } from '../providers/TwitterThemeProvider';
|
||||
import { TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
backgroundModal: {
|
||||
|
||||
@@ -7,6 +7,7 @@ import TweetList from './tweet/TweetList';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import SearchButton from './buttons/SearchButton';
|
||||
import { useFilteredTweets } from '../hooks/useFilteredTweets';
|
||||
import { TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
@@ -32,7 +33,7 @@ function TwitterSearch() {
|
||||
const cleanedSearchValue = searchValue.trim();
|
||||
if (!cleanedSearchValue) return;
|
||||
|
||||
Nui.send('phone:fetchTweetsFiltered', cleanedSearchValue);
|
||||
Nui.send(TwitterEvents.FETCH_TWEETS_FILTERED, cleanedSearchValue);
|
||||
};
|
||||
|
||||
const filteredTweets = tweets || [];
|
||||
|
||||
@@ -4,6 +4,7 @@ import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder';
|
||||
import FavoriteIcon from '@material-ui/icons/Favorite';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
@@ -12,7 +13,7 @@ function LikeButton({ tweetId, isLiked }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send('phone:toggleLike', tweetId);
|
||||
Nui.send(TwitterEvents.TOGGLE_LIKE, tweetId);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setLiked(!liked);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Button, CircularProgress, MenuItem } from '@material-ui/core';
|
||||
import DoneIcon from '@material-ui/icons/Done';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
@@ -12,7 +13,7 @@ function ReportButton({ handleClose, tweetId, isReported }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send('phone:reportTweet', tweetId);
|
||||
Nui.send(TwitterEvents.REPORT, tweetId);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CircularProgress, makeStyles, Button } from '@material-ui/core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
interface IProps {
|
||||
tweetId: number;
|
||||
@@ -33,7 +34,7 @@ export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
|
||||
// if someone is retweeting something that is itself a retweet
|
||||
// then we want to retweet the original post (if we haven't already)
|
||||
const idToRetweet = isRetweet ? retweetId : tweetId;
|
||||
Nui.send('phone:retweet', idToRetweet);
|
||||
Nui.send(TwitterEvents.RETWEET, idToRetweet);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setRetweeted(true);
|
||||
|
||||
@@ -8,6 +8,7 @@ import Avatar from '../Avatar';
|
||||
import ProfileField from './ProfileField';
|
||||
import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -46,7 +47,7 @@ export function Profile() {
|
||||
location,
|
||||
job,
|
||||
};
|
||||
Nui.send('phone:updateTwitterProfile', data);
|
||||
Nui.send(TwitterEvents.UPDATE_PROFILE, data);
|
||||
};
|
||||
|
||||
// fetching the config is an asynchronous call so defend against it
|
||||
|
||||
@@ -10,6 +10,7 @@ import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { twitterState } from '../../hooks/state';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -33,8 +34,8 @@ export function ProfilePrompt() {
|
||||
|
||||
const showDefaultProfileNames = !config.twitter.allowEdtiableProfileName && !profile;
|
||||
const eventName = showDefaultProfileNames
|
||||
? 'phone:createTwitterProfile'
|
||||
: 'phone:updateTwitterProfile';
|
||||
? TwitterEvents.CREATE_PROFILE
|
||||
: TwitterEvents.UPDATE_PROFILE;
|
||||
|
||||
const handleUpdate = () => {
|
||||
Nui.send(eventName, {
|
||||
|
||||
@@ -5,6 +5,7 @@ import MoreIcon from '@material-ui/icons/MoreVert';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import ReportButton from '../buttons/ReportButton';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
||||
@@ -23,7 +24,7 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
};
|
||||
|
||||
const handleDeleteTweet = () => {
|
||||
Nui.send('phone:deleteTweet', id);
|
||||
Nui.send(TwitterEvents.DELETE_TWEET, id);
|
||||
handleClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTweets } from '../../hooks/useTweets';
|
||||
import { useTwitterNotifications } from '../../hooks/useTwitterNotifications';
|
||||
import TweetList from './TweetList';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
export function TweetListContainer() {
|
||||
const { tweets } = useTweets();
|
||||
const { setUnreadCount } = useTwitterNotifications();
|
||||
|
||||
useEffect(() => {
|
||||
Nui.send('phone:fetchTweets', {});
|
||||
Nui.send(TwitterEvents.FETCH_TWEETS, {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Nui from '../../nui-events/utils/Nui';
|
||||
|
||||
export const AppWithStartup = ({ children, id }) => {
|
||||
useEffect(() => {
|
||||
Nui.send(`phone:app:${id}`);
|
||||
Nui.send(`npwd:app:${id}`);
|
||||
}, [id]);
|
||||
return children;
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { useRecoilState } from 'recoil';
|
||||
import { CallProps } from '../../../../../typings/call';
|
||||
import Nui from '../../nui-events/utils/Nui';
|
||||
import { callerState } from './state';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
|
||||
interface CallHook {
|
||||
call: CallProps;
|
||||
@@ -15,19 +16,19 @@ export const useCall = (): CallHook => {
|
||||
const [call, setCall] = useRecoilState(callerState.currentCall);
|
||||
|
||||
const acceptCall = () => {
|
||||
Nui.send('phone:acceptCall', {
|
||||
Nui.send(CallEvents.ACCEPT_CALL, {
|
||||
transmitterNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
const rejectCall = () => {
|
||||
Nui.send('phone:rejectCall', {
|
||||
Nui.send(CallEvents.REJECTED, {
|
||||
phoneNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
const endCall = () => {
|
||||
Nui.send('phone:endCall', {
|
||||
Nui.send(CallEvents.END_CALL, {
|
||||
transmitterNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import ServerConfig from '../../../config.autogen.json';
|
||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||
import Nui from '../../nui-events/utils/Nui';
|
||||
import { phoneState } from './state';
|
||||
import { PhoneEvents } from '../../../../../typings/phone';
|
||||
|
||||
interface IUsePhone {
|
||||
config?: IServerConfig;
|
||||
@@ -21,10 +22,10 @@ export const usePhone = (): IUsePhone => {
|
||||
|
||||
const closePhone = () => {
|
||||
removeAlerts();
|
||||
Nui.send('phone:close');
|
||||
Nui.send(PhoneEvents.CLOSE_PHONE);
|
||||
};
|
||||
const openPhone = () => {
|
||||
Nui.send('phone:open');
|
||||
Nui.send(PhoneEvents.OPEN_PHONE);
|
||||
};
|
||||
|
||||
return { config: ServerConfig as any, closePhone, openPhone, isPhoneOpen, isPhoneReady };
|
||||
|
||||
+10
-3
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
@@ -16,7 +20,10 @@
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"strictNullChecks": false,
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
+4021
-2833
File diff suppressed because it is too large.
Load diff
+10
-10
@@ -1,7 +1,7 @@
|
||||
import { IAlertProps } from '../../typings/alerts';
|
||||
import events from '../utils/events';
|
||||
import { BankEvents } from '../../typings/bank';
|
||||
|
||||
onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
|
||||
onNet(BankEvents.SEND_TRANSFERS, (transfer: any) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'BANK',
|
||||
@@ -11,7 +11,7 @@ onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
|
||||
);
|
||||
});
|
||||
|
||||
onNet(events.BANK_SEND_CREDENTIALS, (credentials: any) => {
|
||||
onNet(BankEvents.SEND_CREDENTIALS, (credentials: any) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'BANK',
|
||||
@@ -21,17 +21,17 @@ onNet(events.BANK_SEND_CREDENTIALS, (credentials: any) => {
|
||||
);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.BANK_ADD_TRANSFER);
|
||||
on(`__cfx_nui:${events.BANK_ADD_TRANSFER}`, (data: any, cb: Function) => {
|
||||
emitNet(events.BANK_ADD_TRANSFER, data);
|
||||
RegisterNuiCallbackType(BankEvents.ADD_TRANSFER);
|
||||
on(`__cfx_nui:${BankEvents.ADD_TRANSFER}`, (data: any, cb: Function) => {
|
||||
emitNet(BankEvents.ADD_TRANSFER, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.BANK_ADD_TRANSFER_SUCCESS, () => {
|
||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||
onNet(BankEvents.ADD_TRANSFER_SUCCESS, () => {
|
||||
emitNet(BankEvents.FETCH_TRANSACTIONS);
|
||||
});
|
||||
|
||||
onNet(events.BANK_TRANSACTION_ALERT, (result: IAlertProps) => {
|
||||
onNet(BankEvents.TRANSACTION_ALERT, (result: IAlertProps) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'BANK',
|
||||
@@ -41,7 +41,7 @@ onNet(events.BANK_TRANSACTION_ALERT, (result: IAlertProps) => {
|
||||
);
|
||||
});
|
||||
|
||||
onNet(events.BANK_TRANSACTION_NOTIFICATION, (transfer: any) => {
|
||||
onNet(BankEvents.TRANSACTION_NOTIFICATION, (transfer: any) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'BANK',
|
||||
|
||||
+35
-38
@@ -1,16 +1,16 @@
|
||||
import events from '../utils/events';
|
||||
import { CallEvents } from '../../typings/call';
|
||||
import { ICall } from '../../typings/call';
|
||||
import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
|
||||
|
||||
const exp = (global as any).exports;
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_INITIALIZE_CALL); // Fires when the call is started.
|
||||
on(`__cfx_nui:${events.PHONE_INITIALIZE_CALL}`, (data: any, cb: Function) => {
|
||||
emitNet(events.PHONE_INITIALIZE_CALL, data.number);
|
||||
RegisterNuiCallbackType(CallEvents.INITIALIZE_CALL); // Fires when the call is started.
|
||||
on(`__cfx_nui:${CallEvents.INITIALIZE_CALL}`, (data: any, cb: Function) => {
|
||||
emitNet(CallEvents.INITIALIZE_CALL, data.number);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.PHONE_START_CALL, (transmitter: string, receiver: string, isTransmitter: boolean) => {
|
||||
onNet(CallEvents.START_CALL, (transmitter: string, receiver: string, isTransmitter: boolean) => {
|
||||
openCallModal(true);
|
||||
|
||||
SendNuiMessage(
|
||||
@@ -28,40 +28,37 @@ onNet(events.PHONE_START_CALL, (transmitter: string, receiver: string, isTransmi
|
||||
);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_ACCEPT_CALL); // Fires when the TARGET accepts.
|
||||
on(`__cfx_nui:${events.PHONE_ACCEPT_CALL}`, (data: any, cb: Function) => {
|
||||
emitNet(events.PHONE_ACCEPT_CALL, data.transmitterNumber);
|
||||
RegisterNuiCallbackType(CallEvents.ACCEPT_CALL); // Fires when the TARGET accepts.
|
||||
on(`__cfx_nui:${CallEvents.ACCEPT_CALL}`, (data: any, cb: Function) => {
|
||||
emitNet(CallEvents.ACCEPT_CALL, data.transmitterNumber);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.PHONE_CALL_WAS_ACCEPTED,
|
||||
(channelId: number, currentCall: ICall, isTransmitter: boolean) => {
|
||||
exp['mumble-voip'].SetCallChannel(channelId);
|
||||
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: currentCall.transmitter,
|
||||
receiver: currentCall.receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmitter: boolean) => {
|
||||
exp['mumble-voip'].SetCallChannel(channelId);
|
||||
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: currentCall.transmitter,
|
||||
receiver: currentCall.receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_CALL_REJECTED); // Fires when cancelling and rejecting a call.
|
||||
on(`__cfx_nui:${events.PHONE_CALL_REJECTED}`, (data: any, cb: Function) => {
|
||||
emitNet(events.PHONE_CALL_REJECTED, data.phoneNumber);
|
||||
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
|
||||
on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => {
|
||||
emitNet(CallEvents.REJECTED, data.phoneNumber);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.PHONE_CALL_WAS_REJECTED, () => {
|
||||
onNet(CallEvents.WAS_REJECTED, () => {
|
||||
openCallModal(false);
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
@@ -78,18 +75,18 @@ onNet(events.PHONE_CALL_WAS_REJECTED, () => {
|
||||
);
|
||||
});
|
||||
|
||||
onNet(events.PHONE_CALL_SEND_HANGUP_ANIM, () => {
|
||||
onNet(CallEvents.SEND_HANGUP_ANIM, () => {
|
||||
phoneCallEndAnim();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_END_CALL); // Fires when ending an ACTIVE call
|
||||
on(`__cfx_nui:${events.PHONE_END_CALL}`, (data: any, cb: Function) => {
|
||||
RegisterNuiCallbackType(CallEvents.END_CALL); // Fires when ending an ACTIVE call
|
||||
on(`__cfx_nui:${CallEvents.END_CALL}`, (data: any, cb: Function) => {
|
||||
const end = Date.now();
|
||||
emitNet(events.PHONE_END_CALL, data.transmitterNumber, end);
|
||||
emitNet(CallEvents.END_CALL, data.transmitterNumber, end);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.PHONE_CALL_WAS_ENDED, () => {
|
||||
onNet(CallEvents.WAS_ENDED, () => {
|
||||
exp['mumble-voip'].SetCallChannel(0);
|
||||
openCallModal(false);
|
||||
|
||||
@@ -118,7 +115,7 @@ function openCallModal(show: boolean) {
|
||||
);
|
||||
}
|
||||
|
||||
onNet(events.PHONE_CALL_SEND_HISTORY, (calls: ICall) => {
|
||||
onNet(CallEvents.SEND_HISTORY, (calls: ICall) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'DIALER',
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import events from '../utils/events';
|
||||
import { ContactEvents } from '../../typings/contact';
|
||||
import { sendContactsEvent } from '../utils/messages';
|
||||
|
||||
onNet(events.CONTACTS_SEND_CONTACTS, (contacts: any) => {
|
||||
onNet(ContactEvents.SEND_CONTACTS, (contacts: any) => {
|
||||
sendContactsEvent('setContacts', contacts);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.CONTACTS_ADD_CONTACT);
|
||||
on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(events.CONTACTS_ADD_CONTACT, data.number, data.display, data.avatar);
|
||||
RegisterNuiCallbackType(ContactEvents.ADD_CONTACT);
|
||||
on(`__cfx_nui:${ContactEvents.ADD_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(ContactEvents.ADD_CONTACT, data.number, data.display, data.avatar);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_ADD_CONTACT_SUCCESS, () => {
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
onNet(ContactEvents.ADD_CONTACT_SUCCESS, () => {
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.CONTACTS_UPDATE_CONTACT);
|
||||
on(`__cfx_nui:${events.CONTACTS_UPDATE_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(events.CONTACTS_UPDATE_CONTACT, data);
|
||||
RegisterNuiCallbackType(ContactEvents.UPDATE_CONTACT);
|
||||
on(`__cfx_nui:${ContactEvents.UPDATE_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(ContactEvents.UPDATE_CONTACT, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, () => {
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
onNet(ContactEvents.UPDATE_CONTACT_SUCCESS, () => {
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.CONTACTS_DELETE_CONTACT);
|
||||
on(`__cfx_nui:${events.CONTACTS_DELETE_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(events.CONTACTS_DELETE_CONTACT, data);
|
||||
RegisterNuiCallbackType(ContactEvents.DELETE_CONTACT);
|
||||
on(`__cfx_nui:${ContactEvents.DELETE_CONTACT}`, (data: any, cb: Function) => {
|
||||
emitNet(ContactEvents.DELETE_CONTACT, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, () => {
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
onNet(ContactEvents.DELETE_CONTACT_SUCCESS, () => {
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_ACTION_RESULT, (alert: any) => {
|
||||
onNet(ContactEvents.ACTION_RESULT, (alert: any) => {
|
||||
sendContactsEvent('setAlert', alert);
|
||||
});
|
||||
+31
-23
@@ -1,7 +1,15 @@
|
||||
import config from '../utils/config';
|
||||
import events from '../utils/events';
|
||||
import { sendMessage } from '../utils/messages';
|
||||
import { PhoneEvents } from '../../typings/phone';
|
||||
import { TwitterEvents } from '../../typings/twitter';
|
||||
import { ContactEvents } from '../../typings/contact';
|
||||
import { MarketplaceEvents } from '../../typings/marketplace';
|
||||
import { phoneCloseAnim, phoneOpenAnim, removePhoneProp } from './functions';
|
||||
import { MessageEvents } from '../../typings/messages';
|
||||
import { NotesEvents } from '../../typings/notes';
|
||||
import { BankEvents } from '../../typings/bank';
|
||||
import { PhotoEvents } from '../../typings/photo';
|
||||
import { CallEvents } from '../../typings/call';
|
||||
|
||||
let isPhoneOpen = false;
|
||||
let isPhoneReady = false;
|
||||
@@ -13,9 +21,9 @@ let isPhoneReady = false;
|
||||
* * * * * * * * * * * * */
|
||||
function fetchOnInitialize() {
|
||||
isPhoneReady = true;
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
|
||||
sendMessage('PHONE', 'phoneConfig', config);
|
||||
}
|
||||
@@ -88,7 +96,7 @@ async function Phone(): Promise<void> {
|
||||
}
|
||||
|
||||
// triggerd when the player is ready
|
||||
onNet(events.PLAYER_IS_READY, fetchOnInitialize);
|
||||
onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
|
||||
|
||||
AddEventHandler('onResourceStop', function (resource: string) {
|
||||
if (resource === GetCurrentResourceName()) {
|
||||
@@ -111,39 +119,39 @@ onNet('phone:sendCredentials', (number: string) => {
|
||||
* NUI Service Callback Registration
|
||||
*
|
||||
* * * * * * * * * * * * */
|
||||
RegisterNuiCallbackType(events.OPEN_APP_LISTINGS);
|
||||
on(`__cfx_nui:${events.OPEN_APP_LISTINGS}`, (data: any, cb: Function) => {
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
RegisterNuiCallbackType(PhoneEvents.OPEN_APP_LISTINGS);
|
||||
on(`__cfx_nui:${PhoneEvents.OPEN_APP_LISTINGS}`, (data: any, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.OPEN_APP_NOTES);
|
||||
on(`__cfx_nui:${events.OPEN_APP_NOTES}`, (data: any, cb: Function) => {
|
||||
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||
RegisterNuiCallbackType(PhoneEvents.OPEN_APP_NOTES);
|
||||
on(`__cfx_nui:${PhoneEvents.OPEN_APP_NOTES}`, (data: any, cb: Function) => {
|
||||
emitNet(NotesEvents.FETCH_ALL_NOTES);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.OPEN_APP_BANK);
|
||||
on(`__cfx_nui:${events.OPEN_APP_BANK}`, (data: any, cb: Function) => {
|
||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||
emitNet(events.BANK_GET_CREDENTIALS);
|
||||
RegisterNuiCallbackType(PhoneEvents.OPEN_APP_BANK);
|
||||
on(`__cfx_nui:${PhoneEvents.OPEN_APP_BANK}`, (data: any, cb: Function) => {
|
||||
emitNet(BankEvents.FETCH_TRANSACTIONS);
|
||||
emitNet(BankEvents.GET_CREDENTIALS);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.OPEN_APP_CAMERA);
|
||||
on(`__cfx_nui:${events.OPEN_APP_CAMERA}`, (data: any, cb: Function) => {
|
||||
emitNet(events.CAMERA_FETCH_PHOTOS);
|
||||
RegisterNuiCallbackType(PhoneEvents.OPEN_APP_CAMERA);
|
||||
on(`__cfx_nui:${PhoneEvents.OPEN_APP_CAMERA}`, (data: any, cb: Function) => {
|
||||
emitNet(PhotoEvents.FETCH_PHOTOS);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.OPEN_APP_DAILER);
|
||||
on(`__cfx_nui:${events.OPEN_APP_DAILER}`, (data: any, cb: Function) => {
|
||||
emitNet(events.PHONE_CALL_FETCH_CALLS);
|
||||
RegisterNuiCallbackType(PhoneEvents.OPEN_APP_DAILER);
|
||||
on(`__cfx_nui:${PhoneEvents.OPEN_APP_DAILER}`, (data: any, cb: Function) => {
|
||||
emitNet(CallEvents.FETCH_CALLS);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType('phone:close');
|
||||
on(`__cfx_nui:phone:close`, async (data: any, cb: Function) => {
|
||||
RegisterNuiCallbackType(PhoneEvents.CLOSE_PHONE);
|
||||
on(`__cfx_nui:${PhoneEvents.CLOSE_PHONE}`, async (data: any, cb: Function) => {
|
||||
await hidePhone();
|
||||
cb();
|
||||
}); // Called for when the phone is closed via the UI.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import events from '../utils/events';
|
||||
import {
|
||||
CreateMessageBroadcast,
|
||||
Message,
|
||||
MessageEvents,
|
||||
MessageGroup,
|
||||
SetMessageRead,
|
||||
} from '../../typings/messages';
|
||||
@@ -10,90 +10,90 @@ import { sendMessageEvent } from '../utils/messages';
|
||||
/**
|
||||
* Messages get message groups
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
on(`__cfx_nui:${events.MESSAGES_FETCH_MESSAGE_GROUPS}`, (): void => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
RegisterNuiCallbackType(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
on(`__cfx_nui:${MessageEvents.FETCH_MESSAGE_GROUPS}`, (): void => {
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, (messageGroups: MessageGroup[]): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, messageGroups);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS);
|
||||
onNet(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS, (messageGroups: MessageGroup[]): void => {
|
||||
sendMessageEvent(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS, messageGroups);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, () => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED);
|
||||
onNet(MessageEvents.FETCH_MESSAGE_GROUPS_FAILED, () => {
|
||||
sendMessageEvent(MessageEvents.FETCH_MESSAGE_GROUPS_FAILED);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, () => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
onNet(MessageEvents.FETCH_MESSAGE_GROUPS, () => {
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
});
|
||||
|
||||
/**
|
||||
* Messages create message group
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_CREATE_MESSAGE_GROUP);
|
||||
RegisterNuiCallbackType(MessageEvents.CREATE_MESSAGE_GROUP);
|
||||
on(
|
||||
`__cfx_nui:${events.MESSAGES_CREATE_MESSAGE_GROUP}`,
|
||||
`__cfx_nui:${MessageEvents.CREATE_MESSAGE_GROUP}`,
|
||||
({ phoneNumbers, label }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP, phoneNumbers, label);
|
||||
emitNet(MessageEvents.CREATE_MESSAGE_GROUP, phoneNumbers, label);
|
||||
cb();
|
||||
},
|
||||
);
|
||||
|
||||
onNet(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, (result: any): void => {
|
||||
sendMessageEvent(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, result);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
onNet(MessageEvents.CREATE_MESSAGE_GROUP_SUCCESS, (result: any): void => {
|
||||
sendMessageEvent(MessageEvents.CREATE_MESSAGE_GROUP_SUCCESS, result);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, (result: any): void => {
|
||||
sendMessageEvent(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, result);
|
||||
onNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, (result: any): void => {
|
||||
sendMessageEvent(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, result);
|
||||
});
|
||||
|
||||
/**
|
||||
* Messages fetch messages
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_FETCH_MESSAGES);
|
||||
on(`__cfx_nui:${events.MESSAGES_FETCH_MESSAGES}`, ({ groupId }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGES, groupId);
|
||||
RegisterNuiCallbackType(MessageEvents.FETCH_MESSAGES);
|
||||
on(`__cfx_nui:${MessageEvents.FETCH_MESSAGES}`, ({ groupId }: any, cb: Function): void => {
|
||||
emitNet(MessageEvents.FETCH_MESSAGES, groupId);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.MESSAGES_SET_MESSAGE_READ);
|
||||
on(`__cfx_nui:${events.MESSAGES_SET_MESSAGE_READ}`, (data: SetMessageRead, cb: Function) => {
|
||||
emitNet(events.MESSAGES_SET_MESSAGE_READ, data.groupId);
|
||||
RegisterNuiCallbackType(MessageEvents.SET_MESSAGE_READ);
|
||||
on(`__cfx_nui:${MessageEvents.SET_MESSAGE_READ}`, (data: SetMessageRead, cb: Function) => {
|
||||
emitNet(MessageEvents.SET_MESSAGE_READ, data.groupId);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, (messages: Message[]): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGES_SUCCESS, messages);
|
||||
onNet(MessageEvents.FETCH_MESSAGES_SUCCESS, (messages: Message[]): void => {
|
||||
sendMessageEvent(MessageEvents.FETCH_MESSAGES_SUCCESS, messages);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGES_FAILED, (): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGES_FAILED);
|
||||
onNet(MessageEvents.FETCH_MESSAGES_FAILED, (): void => {
|
||||
sendMessageEvent(MessageEvents.FETCH_MESSAGES_FAILED);
|
||||
});
|
||||
|
||||
/**
|
||||
* Messages send message
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_SEND_MESSAGE);
|
||||
on(`__cfx_nui:${events.MESSAGES_SEND_MESSAGE}`, (data: any, cb: Function) => {
|
||||
emitNet(events.MESSAGES_SEND_MESSAGE, data.groupId, data.message, data.groupName);
|
||||
RegisterNuiCallbackType(MessageEvents.SEND_MESSAGE);
|
||||
on(`__cfx_nui:${MessageEvents.SEND_MESSAGE}`, (data: any, cb: Function) => {
|
||||
emitNet(MessageEvents.SEND_MESSAGE, data.groupId, data.message, data.groupName);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_SEND_MESSAGE_SUCCESS, (groupId: string) => {
|
||||
sendMessageEvent(events.MESSAGES_SEND_MESSAGE_SUCCESS);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGES, groupId);
|
||||
onNet(MessageEvents.SEND_MESSAGE_SUCCESS, (groupId: string) => {
|
||||
sendMessageEvent(MessageEvents.SEND_MESSAGE_SUCCESS);
|
||||
emitNet(MessageEvents.FETCH_MESSAGES, groupId);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_SEND_MESSAGE_FAILED, () => {
|
||||
sendMessageEvent(events.MESSAGES_SEND_MESSAGE_FAILED);
|
||||
onNet(MessageEvents.SEND_MESSAGE_FAILED, () => {
|
||||
sendMessageEvent(MessageEvents.SEND_MESSAGE_FAILED);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_ACTION_RESULT, (result: any) => {
|
||||
sendMessageEvent(events.MESSAGES_ACTION_RESULT, result);
|
||||
onNet(MessageEvents.ACTION_RESULT, (result: any) => {
|
||||
sendMessageEvent(MessageEvents.ACTION_RESULT, result);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_CREATE_MESSAGE_BROADCAST, (result: CreateMessageBroadcast) => {
|
||||
sendMessageEvent(events.MESSAGES_CREATE_MESSAGE_BROADCAST, result);
|
||||
onNet(MessageEvents.CREATE_MESSAGE_BROADCAST, (result: CreateMessageBroadcast) => {
|
||||
sendMessageEvent(MessageEvents.CREATE_MESSAGE_BROADCAST, result);
|
||||
});
|
||||
@@ -1,39 +1,39 @@
|
||||
import events from '../utils/events';
|
||||
import { NotesEvents } from '../../typings/notes';
|
||||
import { sendNotesEvent } from '../utils/messages';
|
||||
|
||||
onNet(events.NOTE_SEND_NOTE, (notes: any) => {
|
||||
onNet(NotesEvents.SEND_NOTE, (notes: any) => {
|
||||
sendNotesEvent('setNotes', notes);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.NOTE_ADD_NOTE);
|
||||
on(`__cfx_nui:${events.NOTE_ADD_NOTE}`, (data: any) => {
|
||||
emitNet(events.NOTE_ADD_NOTE, data);
|
||||
RegisterNuiCallbackType(NotesEvents.ADD_NOTE);
|
||||
on(`__cfx_nui:${NotesEvents.ADD_NOTE}`, (data: any) => {
|
||||
emitNet(NotesEvents.ADD_NOTE, data);
|
||||
});
|
||||
|
||||
onNet(events.NOTE_SEND_NOTE_SUCCESS, () => {
|
||||
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||
onNet(NotesEvents.SEND_NOTE_SUCCESS, () => {
|
||||
emitNet(NotesEvents.FETCH_ALL_NOTES);
|
||||
});
|
||||
|
||||
onNet(events.NOTE_DELETE_NOTE_SUCCESS, () => {
|
||||
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||
onNet(NotesEvents.DELETE_NOTE_SUCCESS, () => {
|
||||
emitNet(NotesEvents.FETCH_ALL_NOTES);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.NOTE_DELETE_NOTE);
|
||||
on(`__cfx_nui:${events.NOTE_DELETE_NOTE}`, (data: any) => {
|
||||
emitNet(events.NOTE_DELETE_NOTE, data);
|
||||
RegisterNuiCallbackType(NotesEvents.DELETE_NOTE);
|
||||
on(`__cfx_nui:${NotesEvents.DELETE_NOTE}`, (data: any) => {
|
||||
emitNet(NotesEvents.DELETE_NOTE, data);
|
||||
|
||||
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||
emitNet(NotesEvents.FETCH_ALL_NOTES);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.NOTE_UPDATE_NOTE);
|
||||
on(`__cfx_nui:${events.NOTE_UPDATE_NOTE}`, (data: any) => {
|
||||
emitNet(events.NOTE_UPDATE_NOTE, data);
|
||||
RegisterNuiCallbackType(NotesEvents.UPDATE_NOTE);
|
||||
on(`__cfx_nui:${NotesEvents.UPDATE_NOTE}`, (data: any) => {
|
||||
emitNet(NotesEvents.UPDATE_NOTE, data);
|
||||
});
|
||||
|
||||
onNet(events.NOTE_UPDATE_NOTE_SUCCESS, () => {
|
||||
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||
onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => {
|
||||
emitNet(NotesEvents.FETCH_ALL_NOTES);
|
||||
});
|
||||
|
||||
onNet(events.NOTE_ACTION_RESULT, (alert: any) => {
|
||||
onNet(NotesEvents.ACTION_RESULT, (alert: any) => {
|
||||
sendNotesEvent('setAlert', alert);
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import events from '../utils/events';
|
||||
import { PhotoEvents } from '../../typings/photo';
|
||||
import { Delay } from '../utils/fivem';
|
||||
import { sendMessage, sendCameraEvent } from '../utils/messages';
|
||||
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
|
||||
@@ -28,8 +28,8 @@ const displayHelperText = () => {
|
||||
EndTextCommandDisplayHelp(0, true, false, -1);
|
||||
};
|
||||
|
||||
RegisterNuiCallbackType(events.CAMERA_TAKE_PHOTO);
|
||||
on(`__cfx_nui:${events.CAMERA_TAKE_PHOTO}`, async (data: any, cb: Function) => {
|
||||
RegisterNuiCallbackType(PhotoEvents.TAKE_PHOTO);
|
||||
on(`__cfx_nui:${PhotoEvents.TAKE_PHOTO}`, async (data: any, cb: Function) => {
|
||||
cb();
|
||||
// Create Phone Prop
|
||||
let frontCam = false;
|
||||
@@ -75,7 +75,7 @@ const handleCameraExit = () => {
|
||||
inCameraMode = false;
|
||||
};
|
||||
|
||||
onNet(events.CAMERA_SEND_PHOTOS, (photos: string[]) => {
|
||||
onNet(PhotoEvents.SEND_PHOTOS, (photos: string[]) => {
|
||||
sendCameraEvent('setPhotos', photos);
|
||||
});
|
||||
|
||||
@@ -95,23 +95,23 @@ function takePhoto() {
|
||||
},
|
||||
(data: string) => {
|
||||
const imageLink = JSON.parse(data).data.link;
|
||||
emitNet(events.CAMERA_UPLOAD_PHOTO, imageLink);
|
||||
emitNet(PhotoEvents.UPLOAD_PHOTO, imageLink);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
onNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, () => {
|
||||
emitNet(events.CAMERA_FETCH_PHOTOS);
|
||||
onNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, () => {
|
||||
emitNet(PhotoEvents.FETCH_PHOTOS);
|
||||
});
|
||||
|
||||
// delete photo
|
||||
|
||||
RegisterNuiCallbackType(events.CAMERA_DELETE_PHOTO);
|
||||
on(`__cfx_nui:${events.CAMERA_DELETE_PHOTO}`, (data: any, cb: Function) => {
|
||||
emitNet(events.CAMERA_DELETE_PHOTO, data);
|
||||
RegisterNuiCallbackType(PhotoEvents.DELETE_PHOTO);
|
||||
on(`__cfx_nui:${PhotoEvents.DELETE_PHOTO}`, (data: any, cb: Function) => {
|
||||
emitNet(PhotoEvents.DELETE_PHOTO, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_DELETE_PHOTO_SUCCESS, () => {
|
||||
emitNet(events.CAMERA_FETCH_PHOTOS);
|
||||
onNet(PhotoEvents.DELETE_PHOTO_SUCCESS, () => {
|
||||
emitNet(PhotoEvents.FETCH_PHOTOS);
|
||||
});
|
||||
@@ -1,38 +1,38 @@
|
||||
import events from '../utils/events';
|
||||
import { MarketplaceListing } from '../../typings/marketplace';
|
||||
import { MarketplaceEvents, MarketplaceListing } from '../../typings/marketplace';
|
||||
import { IAlertProps } from '../../typings/alerts';
|
||||
import { sendMarketplaceEvent } from '../utils/messages';
|
||||
|
||||
onNet(events.SELLOUT_SEND_LISTING, (listing: MarketplaceListing) => {
|
||||
RegisterNuiCallbackType(MarketplaceEvents.ADD_LISTING);
|
||||
|
||||
onNet(MarketplaceEvents.SEND_LISTING, (listing: MarketplaceListing) => {
|
||||
sendMarketplaceEvent('setListing', listing);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.SELLOUT_ADD_LISTING);
|
||||
on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(events.SELLOUT_ADD_LISTING, data);
|
||||
on(`__cfx_nui:${MarketplaceEvents.ADD_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.ADD_LISTING, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.SELLOUT_DELETE_LISTING);
|
||||
on(`__cfx_nui:${events.SELLOUT_DELETE_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(events.SELLOUT_DELETE_LISTING, data.id);
|
||||
RegisterNuiCallbackType(MarketplaceEvents.DELETE_LISTING);
|
||||
on(`__cfx_nui:${MarketplaceEvents.DELETE_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.DELETE_LISTING, data.id);
|
||||
cb();
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.SELLOUT_REPORT_LISTING);
|
||||
on(`__cfx_nui:${events.SELLOUT_REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(events.SELLOUT_REPORT_LISTING, data);
|
||||
RegisterNuiCallbackType(MarketplaceEvents.REPORT_LISTING);
|
||||
on(`__cfx_nui:${MarketplaceEvents.REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.REPORT_LISTING, data);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_ADD_LISTING_SUCCESS, () => {
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
onNet(MarketplaceEvents.ADD_LISTING_SUCCESS, () => {
|
||||
emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_DELETE_LISTING_SUCCESS, () => {
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
onNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, () => {
|
||||
emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_ACTION_RESULT, (alert: IAlertProps) => {
|
||||
onNet(MarketplaceEvents.ACTION_RESULT, (alert: IAlertProps) => {
|
||||
sendMarketplaceEvent('setAlert', alert);
|
||||
});
|
||||
@@ -1,157 +1,157 @@
|
||||
import events from '../utils/events';
|
||||
import { TwitterEvents } from '../../typings/twitter';
|
||||
import { sendTwitterMessage } from '../utils/messages';
|
||||
import { IAlertProps } from '../../typings/alerts';
|
||||
|
||||
/**
|
||||
* Twitter get or create profile
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
on(`__cfx_nui:${events.TWITTER_GET_OR_CREATE_PROFILE}`, () => {
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
RegisterNuiCallbackType(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
on(`__cfx_nui:${TwitterEvents.GET_OR_CREATE_PROFILE}`, () => {
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_GET_OR_CREATE_PROFILE_SUCCESS, (profile: any) => {
|
||||
sendTwitterMessage(events.TWITTER_GET_OR_CREATE_PROFILE_SUCCESS, profile);
|
||||
onNet(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, (profile: any) => {
|
||||
sendTwitterMessage(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, profile);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_GET_OR_CREATE_PROFILE_FAILURE, () => {
|
||||
sendTwitterMessage(events.TWITTER_GET_OR_CREATE_PROFILE_FAILURE);
|
||||
onNet(TwitterEvents.GET_OR_CREATE_PROFILE_FAILURE, () => {
|
||||
sendTwitterMessage(TwitterEvents.GET_OR_CREATE_PROFILE_FAILURE);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_GET_OR_CREATE_PROFILE_NULL, (defaultProfileNames: string[]): void => {
|
||||
sendTwitterMessage(events.TWITTER_GET_OR_CREATE_PROFILE_NULL, defaultProfileNames);
|
||||
onNet(TwitterEvents.GET_OR_CREATE_PROFILE_NULL, (defaultProfileNames: string[]): void => {
|
||||
sendTwitterMessage(TwitterEvents.GET_OR_CREATE_PROFILE_NULL, defaultProfileNames);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter create profile
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_CREATE_PROFILE);
|
||||
on(`__cfx_nui:${events.TWITTER_CREATE_PROFILE}`, (data: any) => {
|
||||
sendTwitterMessage(events.TWITTER_UPDATE_PROFILE_LOADING, true);
|
||||
emitNet(events.TWITTER_CREATE_PROFILE, data);
|
||||
RegisterNuiCallbackType(TwitterEvents.CREATE_PROFILE);
|
||||
on(`__cfx_nui:${TwitterEvents.CREATE_PROFILE}`, (data: any) => {
|
||||
sendTwitterMessage(TwitterEvents.UPDATE_PROFILE_LOADING, true);
|
||||
emitNet(TwitterEvents.CREATE_PROFILE, data);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_PROFILE_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(events.TWITTER_CREATE_PROFILE_RESULT, alert);
|
||||
sendTwitterMessage(events.TWITTER_UPDATE_PROFILE_LOADING, false);
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
onNet(TwitterEvents.CREATE_PROFILE_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(TwitterEvents.CREATE_PROFILE_RESULT, alert);
|
||||
sendTwitterMessage(TwitterEvents.UPDATE_PROFILE_LOADING, false);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter update profile
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_UPDATE_PROFILE);
|
||||
on(`__cfx_nui:${events.TWITTER_UPDATE_PROFILE}`, (data: string) => {
|
||||
sendTwitterMessage(events.TWITTER_UPDATE_PROFILE_LOADING, true);
|
||||
emitNet(events.TWITTER_UPDATE_PROFILE, data);
|
||||
RegisterNuiCallbackType(TwitterEvents.UPDATE_PROFILE);
|
||||
on(`__cfx_nui:${TwitterEvents.UPDATE_PROFILE}`, (data: string) => {
|
||||
sendTwitterMessage(TwitterEvents.UPDATE_PROFILE_LOADING, true);
|
||||
emitNet(TwitterEvents.UPDATE_PROFILE, data);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_UPDATE_PROFILE_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(events.TWITTER_UPDATE_PROFILE_RESULT, alert);
|
||||
sendTwitterMessage(events.TWITTER_UPDATE_PROFILE_LOADING, false);
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
onNet(TwitterEvents.UPDATE_PROFILE_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(TwitterEvents.UPDATE_PROFILE_RESULT, alert);
|
||||
sendTwitterMessage(TwitterEvents.UPDATE_PROFILE_LOADING, false);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter fetch tweets
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_FETCH_TWEETS);
|
||||
on(`__cfx_nui:${events.TWITTER_FETCH_TWEETS}`, () => {
|
||||
emitNet(events.TWITTER_FETCH_TWEETS);
|
||||
RegisterNuiCallbackType(TwitterEvents.FETCH_TWEETS);
|
||||
on(`__cfx_nui:${TwitterEvents.FETCH_TWEETS}`, () => {
|
||||
emitNet(TwitterEvents.FETCH_TWEETS);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS_SUCCESS, (tweets: any) => {
|
||||
sendTwitterMessage(events.TWITTER_FETCH_TWEETS_SUCCESS, tweets);
|
||||
onNet(TwitterEvents.FETCH_TWEETS_SUCCESS, (tweets: any) => {
|
||||
sendTwitterMessage(TwitterEvents.FETCH_TWEETS_SUCCESS, tweets);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS_FAILURE, () => {
|
||||
sendTwitterMessage(events.TWITTER_FETCH_TWEETS_FAILURE);
|
||||
onNet(TwitterEvents.FETCH_TWEETS_FAILURE, () => {
|
||||
sendTwitterMessage(TwitterEvents.FETCH_TWEETS_FAILURE);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter fetch filtered tweets
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_FETCH_TWEETS_FILTERED);
|
||||
on(`__cfx_nui:${events.TWITTER_FETCH_TWEETS_FILTERED}`, (searchValue: string) => {
|
||||
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED, searchValue);
|
||||
RegisterNuiCallbackType(TwitterEvents.FETCH_TWEETS_FILTERED);
|
||||
on(`__cfx_nui:${TwitterEvents.FETCH_TWEETS_FILTERED}`, (searchValue: string) => {
|
||||
emitNet(TwitterEvents.FETCH_TWEETS_FILTERED, searchValue);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS_FILTERED_SUCCESS, (tweets: any) => {
|
||||
sendTwitterMessage(events.TWITTER_FETCH_TWEETS_FILTERED_SUCCESS, tweets);
|
||||
onNet(TwitterEvents.FETCH_TWEETS_FILTERED_SUCCESS, (tweets: any) => {
|
||||
sendTwitterMessage(TwitterEvents.FETCH_TWEETS_FILTERED_SUCCESS, tweets);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS_FILTERED_FAILURE, () => {
|
||||
sendTwitterMessage(events.TWITTER_FETCH_TWEETS_FILTERED_FAILURE);
|
||||
onNet(TwitterEvents.FETCH_TWEETS_FILTERED_FAILURE, () => {
|
||||
sendTwitterMessage(TwitterEvents.FETCH_TWEETS_FILTERED_FAILURE);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter create tweet
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_CREATE_TWEET);
|
||||
on(`__cfx_nui:${events.TWITTER_CREATE_TWEET}`, (data: string) => {
|
||||
sendTwitterMessage(events.TWITTER_CREATE_TWEET_LOADING, true);
|
||||
emitNet(events.TWITTER_CREATE_TWEET, data);
|
||||
RegisterNuiCallbackType(TwitterEvents.CREATE_TWEET);
|
||||
on(`__cfx_nui:${TwitterEvents.CREATE_TWEET}`, (data: string) => {
|
||||
sendTwitterMessage(TwitterEvents.CREATE_TWEET_LOADING, true);
|
||||
emitNet(TwitterEvents.CREATE_TWEET, data);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_TWEET_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(events.TWITTER_CREATE_TWEET_RESULT, alert);
|
||||
emitNet(events.TWITTER_FETCH_TWEETS);
|
||||
onNet(TwitterEvents.CREATE_TWEET_RESULT, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(TwitterEvents.CREATE_TWEET_RESULT, alert);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_TWEET_FAILURE, () => {
|
||||
sendTwitterMessage(events.TWITTER_CREATE_TWEET_FAILURE);
|
||||
onNet(TwitterEvents.CREATE_TWEET_FAILURE, () => {
|
||||
sendTwitterMessage(TwitterEvents.CREATE_TWEET_FAILURE);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_TWEET_BROADCAST, (tweet: any) => {
|
||||
sendTwitterMessage(events.TWITTER_CREATE_TWEET_BROADCAST, tweet);
|
||||
onNet(TwitterEvents.CREATE_TWEET_BROADCAST, (tweet: any) => {
|
||||
sendTwitterMessage(TwitterEvents.CREATE_TWEET_BROADCAST, tweet);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter delete tweet
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_DELETE_TWEET);
|
||||
on(`__cfx_nui:${events.TWITTER_DELETE_TWEET}`, (tweetId: number) => {
|
||||
emitNet(events.TWITTER_DELETE_TWEET, tweetId);
|
||||
RegisterNuiCallbackType(TwitterEvents.DELETE_TWEET);
|
||||
on(`__cfx_nui:${TwitterEvents.DELETE_TWEET}`, (tweetId: number) => {
|
||||
emitNet(TwitterEvents.DELETE_TWEET, tweetId);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_DELETE_TWEET_SUCCESS, () => {
|
||||
sendTwitterMessage(events.TWITTER_DELETE_TWEET_SUCCESS);
|
||||
emitNet(events.TWITTER_FETCH_TWEETS);
|
||||
onNet(TwitterEvents.DELETE_TWEET_SUCCESS, () => {
|
||||
sendTwitterMessage(TwitterEvents.DELETE_TWEET_SUCCESS);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_DELETE_TWEET_FAILURE, () => {
|
||||
sendTwitterMessage(events.TWITTER_DELETE_TWEET_FAILURE);
|
||||
onNet(TwitterEvents.DELETE_TWEET_FAILURE, () => {
|
||||
sendTwitterMessage(TwitterEvents.DELETE_TWEET_FAILURE);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter likes
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_TOGGLE_LIKE);
|
||||
on(`__cfx_nui:${events.TWITTER_TOGGLE_LIKE}`, (tweetId: number) => {
|
||||
emitNet(events.TWITTER_TOGGLE_LIKE, tweetId);
|
||||
RegisterNuiCallbackType(TwitterEvents.TOGGLE_LIKE);
|
||||
on(`__cfx_nui:${TwitterEvents.TOGGLE_LIKE}`, (tweetId: number) => {
|
||||
emitNet(TwitterEvents.TOGGLE_LIKE, tweetId);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter retweets
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_RETWEET);
|
||||
on(`__cfx_nui:${events.TWITTER_RETWEET}`, (tweetId: number, cb: Function) => {
|
||||
emitNet(events.TWITTER_RETWEET, tweetId);
|
||||
RegisterNuiCallbackType(TwitterEvents.RETWEET);
|
||||
on(`__cfx_nui:${TwitterEvents.RETWEET}`, (tweetId: number, cb: Function) => {
|
||||
emitNet(TwitterEvents.RETWEET, tweetId);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_RETWEET_EXISTS, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(events.TWITTER_RETWEET_EXISTS, alert);
|
||||
onNet(TwitterEvents.RETWEET_EXISTS, (alert: IAlertProps) => {
|
||||
sendTwitterMessage(TwitterEvents.RETWEET_EXISTS, alert);
|
||||
});
|
||||
|
||||
/**
|
||||
* Twitter reporting tweets
|
||||
*/
|
||||
RegisterNuiCallbackType(events.TWITTER_REPORT);
|
||||
on(`__cfx_nui:${events.TWITTER_REPORT}`, (tweetId: number) => {
|
||||
emitNet(events.TWITTER_REPORT, tweetId);
|
||||
RegisterNuiCallbackType(TwitterEvents.REPORT);
|
||||
on(`__cfx_nui:${TwitterEvents.REPORT}`, (tweetId: number) => {
|
||||
emitNet(TwitterEvents.REPORT, tweetId);
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_REPORT_SUCCESS, () => {
|
||||
emitNet(events.TWITTER_FETCH_TWEETS);
|
||||
onNet(TwitterEvents.REPORT_SUCCESS, () => {
|
||||
emitNet(TwitterEvents.FETCH_TWEETS);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import { mainLogger } from '../sv_logger';
|
||||
import { pool } from '../db';
|
||||
import { generatePhoneNumber } from '../functions';
|
||||
import events from '../../utils/events';
|
||||
import { PhoneEvents } from '../../../typings/phone';
|
||||
|
||||
export const playerLogger = mainLogger.child({
|
||||
module: 'player',
|
||||
@@ -56,7 +56,7 @@ export async function handlePlayerAdd(pSource: number) {
|
||||
playerLogger.debug(newPlayer);
|
||||
|
||||
// Emit to client that player is ready
|
||||
emitNet(events.PLAYER_IS_READY, pSource);
|
||||
emitNet(PhoneEvents.PLAYER_IS_READY, pSource);
|
||||
} catch (e) {
|
||||
playerLogger.error(`Failed to create a new player, ${e.message}`, {
|
||||
source: pSource,
|
||||
|
||||
+11
-12
@@ -1,8 +1,7 @@
|
||||
import events from '../utils/events';
|
||||
import { ESX } from './server';
|
||||
import { getSource } from './functions';
|
||||
import { pool } from './db';
|
||||
import { Transfer, IBankCredentials } from '../../typings/bank';
|
||||
import { Transfer, IBankCredentials, BankEvents } from '../../typings/bank';
|
||||
import { getIdentifier } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
@@ -40,9 +39,9 @@ async function addTransfer(identifier: string, transfer: Transfer): Promise<any>
|
||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||
|
||||
if (transfer.transferAmount > bankBalance) {
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, getSource(), false);
|
||||
} else if (transfer.transferAmount < bankBalance) {
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), true);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, getSource(), true);
|
||||
|
||||
xTarget.addAccountMoney('bank', transfer.transferAmount);
|
||||
xPlayer.removeAccountMoney('bank', transfer.transferAmount);
|
||||
@@ -75,13 +74,13 @@ async function getTransfer(transferId: number): Promise<Transfer> {
|
||||
return { ...transfer };
|
||||
}
|
||||
|
||||
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
onNet(BankEvents.FETCH_TRANSACTIONS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
const transfer = await fetchAllTransactions(_identifier);
|
||||
|
||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
||||
emitNet(BankEvents.SEND_TRANSFERS, _source, transfer);
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch transactions, ${e.message}`, {
|
||||
source: _source,
|
||||
@@ -89,7 +88,7 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
onNet(BankEvents.ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
const _source = getSource();
|
||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||
try {
|
||||
@@ -101,8 +100,8 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
|
||||
//emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
||||
|
||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, _source);
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, _source, {
|
||||
emitNet(BankEvents.ADD_TRANSFER_SUCCESS, _source);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, _source, {
|
||||
message: 'BANK_ALERT_TRANSFER_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -110,18 +109,18 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
bankLogger.error(`Failed to add transaction, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, _source, {
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, _source, {
|
||||
message: 'APPS_BANK_ALERT_TRANSFER_FAILURE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.BANK_GET_CREDENTIALS, () => {
|
||||
onNet(BankEvents.GET_CREDENTIALS, () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const credentials = fetchCredentials();
|
||||
emitNet(events.BANK_SEND_CREDENTIALS, _source, credentials);
|
||||
emitNet(BankEvents.SEND_CREDENTIALS, _source, credentials);
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch credentials, ${e.message}`, {
|
||||
source: _source,
|
||||
|
||||
+17
-23
@@ -1,4 +1,4 @@
|
||||
import events from '../utils/events';
|
||||
import { CallEvents } from '../../typings/call';
|
||||
import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
|
||||
import { getPlayerFromIdentifier } from './functions';
|
||||
import { ICall } from '../../typings/call';
|
||||
@@ -29,7 +29,7 @@ async function fetchCalls(phoneNumber: string): Promise<ICall[]> {
|
||||
|
||||
let calls: Map<string, ICall> = new Map();
|
||||
|
||||
onNet(events.PHONE_INITIALIZE_CALL, async (phoneNumber: string) => {
|
||||
onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
|
||||
const _source = getSource();
|
||||
|
||||
const startCallTimeUnix = new Date().getTime() / 1000;
|
||||
@@ -72,13 +72,13 @@ onNet(events.PHONE_INITIALIZE_CALL, async (phoneNumber: string) => {
|
||||
|
||||
// events
|
||||
// client that is calling
|
||||
emitNet(events.PHONE_START_CALL, _source, transmitterNumber, receiverNumber, true);
|
||||
emitNet(CallEvents.START_CALL, _source, transmitterNumber, receiverNumber, true);
|
||||
|
||||
// client that is being called
|
||||
emitNet(events.PHONE_START_CALL, xReceiver.source, transmitterNumber, receiverNumber, false);
|
||||
emitNet(CallEvents.START_CALL, xReceiver.source, transmitterNumber, receiverNumber, false);
|
||||
});
|
||||
|
||||
onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
onNet(CallEvents.ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
@@ -91,16 +91,10 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
await updateCall(currentCall, true, null);
|
||||
|
||||
// player who is being called
|
||||
emitNet(events.PHONE_CALL_WAS_ACCEPTED, pSource, channelId, currentCall, false);
|
||||
emitNet(CallEvents.WAS_ACCEPTED, pSource, channelId, currentCall, false);
|
||||
|
||||
// player who is calling
|
||||
emitNet(
|
||||
events.PHONE_CALL_WAS_ACCEPTED,
|
||||
currentCall.transmitterSource,
|
||||
channelId,
|
||||
currentCall,
|
||||
true,
|
||||
);
|
||||
emitNet(CallEvents.WAS_ACCEPTED, currentCall.transmitterSource, channelId, currentCall, true);
|
||||
|
||||
currentCall.accepted = true;
|
||||
} catch (e) {
|
||||
@@ -110,7 +104,7 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.PHONE_CALL_REJECTED, async (transmitterNumber: string, timestamp: number) => {
|
||||
onNet(CallEvents.REJECTED, async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
@@ -120,10 +114,10 @@ onNet(events.PHONE_CALL_REJECTED, async (transmitterNumber: string, timestamp: n
|
||||
await updateCall(currentCall, false, timestamp);
|
||||
|
||||
// player who is called and initiasted the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.receiverSource);
|
||||
emitNet(CallEvents.WAS_REJECTED, currentCall.receiverSource);
|
||||
|
||||
// player who is calling and recieved the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
||||
emitNet(CallEvents.WAS_REJECTED, currentCall.transmitterSource);
|
||||
calls.delete(transmitterNumber);
|
||||
} catch (e) {
|
||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
|
||||
@@ -132,7 +126,7 @@ onNet(events.PHONE_CALL_REJECTED, async (transmitterNumber: string, timestamp: n
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.PHONE_END_CALL, async (transmitterNumber: string) => {
|
||||
onNet(CallEvents.END_CALL, async (transmitterNumber: string) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const currentTimeUnix = new Date().getTime() / 1000;
|
||||
@@ -145,13 +139,13 @@ onNet(events.PHONE_END_CALL, async (transmitterNumber: string) => {
|
||||
await updateCall(currentCall, false, currentTimeUnix);
|
||||
|
||||
// player who is being called
|
||||
emitNet(events.PHONE_CALL_WAS_ENDED, currentCall.receiverSource);
|
||||
emitNet(CallEvents.WAS_ENDED, currentCall.receiverSource);
|
||||
// player who is calling
|
||||
emitNet(events.PHONE_CALL_WAS_ENDED, currentCall.transmitterSource);
|
||||
emitNet(CallEvents.WAS_ENDED, currentCall.transmitterSource);
|
||||
// ends animations if call is active
|
||||
if (currentCall.accepted) {
|
||||
emitNet(events.PHONE_CALL_SEND_HANGUP_ANIM, currentCall.receiverSource);
|
||||
emitNet(events.PHONE_CALL_SEND_HANGUP_ANIM, currentCall.transmitterSource);
|
||||
emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.receiverSource);
|
||||
emitNet(CallEvents.SEND_HANGUP_ANIM, currentCall.transmitterSource);
|
||||
}
|
||||
calls.delete(transmitterNumber);
|
||||
} catch (e) {
|
||||
@@ -161,12 +155,12 @@ onNet(events.PHONE_END_CALL, async (transmitterNumber: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
||||
onNet(CallEvents.FETCH_CALLS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const phoneNumber = getPlayer(_source).getPhoneNumber();
|
||||
const calls = await fetchCalls(phoneNumber);
|
||||
emitNet(events.PHONE_CALL_SEND_HISTORY, _source, calls);
|
||||
emitNet(CallEvents.SEND_HISTORY, _source, calls);
|
||||
} catch (e) {
|
||||
callLogger.error(`Failed to fetch calls, ${e.message}`, {
|
||||
source: _source,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { pool } from './db';
|
||||
import events from '../utils/events';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
import { ContactEvents } from '../../typings/contact';
|
||||
|
||||
const contactsLogger = mainLogger.child({ module: 'contact' });
|
||||
|
||||
@@ -52,30 +52,30 @@ async function deleteContact(contact: ContactId, identifier: string): Promise<an
|
||||
await pool.query(query, [contact.id, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||
onNet(ContactEvents.GET_CONTACTS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
|
||||
const contacts = await fetchAllContacts(_identifier);
|
||||
emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts);
|
||||
emitNet(ContactEvents.SEND_CONTACTS, _source, contacts);
|
||||
} catch (e) {
|
||||
contactsLogger.error(`Failed to fetch contacts, ${e.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avatar: string) => {
|
||||
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(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.ADD_CONTACT_SUCCESS, _source);
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
@@ -85,21 +85,21 @@ onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avata
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||
onNet(ContactEvents.UPDATE_CONTACT, async (contact: Contacts) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
await updateContact(contact, _identifier);
|
||||
|
||||
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
||||
emitNet(ContactEvents.UPDATE_CONTACT_SUCCESS, _source);
|
||||
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_UPDATE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
const _source = (global as any).source;
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_UPDATE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
@@ -109,13 +109,13 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||
onNet(ContactEvents.DELETE_CONTACT, async (contact: ContactId) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
await deleteContact(contact, _identifier);
|
||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.DELETE_CONTACT_SUCCESS, _source);
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_DELETE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -123,7 +123,7 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||
contactsLogger.error(`Failed to delete contact, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
emitNet(ContactEvents.ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_DELETE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import events from '../utils/events';
|
||||
import { CreateMessageGroupResult, Message, MessageGroup } from '../../typings/messages';
|
||||
import {
|
||||
CreateMessageGroupResult,
|
||||
Message,
|
||||
MessageGroup,
|
||||
MessageEvents,
|
||||
} from '../../typings/messages';
|
||||
import { pool, withTransaction } from './db';
|
||||
import { getIdentifier, getSource, getPlayerFromIdentifier } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
@@ -404,104 +408,84 @@ async function setMessageRead(groupId: string, identifier: string) {
|
||||
await pool.query(query, [groupId, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
|
||||
onNet(MessageEvents.FETCH_MESSAGE_GROUPS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
const messageGroups = await getFormattedMessageGroups(identifier);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, _source, messageGroups);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_SUCCESS, _source, messageGroups);
|
||||
} catch (e) {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, _source);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS_FAILED, _source);
|
||||
messageLogger.error(`Failed to fetch messages groups, ${e.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.MESSAGES_CREATE_MESSAGE_GROUP,
|
||||
async (phoneNumbers: string[], label: string = null) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
|
||||
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.duplicate) {
|
||||
return emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_DUPLICATE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
if (result.error && result.duplicate) {
|
||||
return emitNet(MessageEvents.ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_DUPLICATE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
// if the phoneNumber is invalid
|
||||
if (result.error && result.phoneNumber) {
|
||||
return emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_INVALID_PHONE_NUMBER',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
// if you are try to add yourself
|
||||
if (result.error && result.mine) {
|
||||
return emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_CREATE_MINE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
// if it just fails, welp
|
||||
if (result.error) {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source, result);
|
||||
return emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: `MESSAGES_MESSAGE_GROUP_CREATE_FAILED:`,
|
||||
type: 'error',
|
||||
});
|
||||
} else {
|
||||
emitNet(events.MESSAGES_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(events.MESSAGES_FETCH_MESSAGE_GROUPS, participantPlayer.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source);
|
||||
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
if (result.error) {
|
||||
emitNet(MessageEvents.CREATE_MESSAGE_GROUP_FAILED, _source, result);
|
||||
return emitNet(MessageEvents.ACTION_RESULT, _source, {
|
||||
message: `MESSAGES_MESSAGE_GROUP_CREATE_FAILED:`,
|
||||
type: 'error',
|
||||
});
|
||||
messageLogger.error(`Failed to create message group, ${e.message}`, {
|
||||
source: _source,
|
||||
e,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
||||
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: `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(events.MESSAGES_FETCH_MESSAGES_SUCCESS, _source, messages);
|
||||
emitNet(MessageEvents.FETCH_MESSAGES_SUCCESS, _source, messages);
|
||||
} catch (e) {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGES_FAILED, _source);
|
||||
emitNet(MessageEvents.FETCH_MESSAGES_FAILED, _source);
|
||||
messageLogger.error(`Failed to fetch messages, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, groupName: string) => {
|
||||
onNet(MessageEvents.SEND_MESSAGE, async (groupId: string, message: string, groupName: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
@@ -509,7 +493,7 @@ onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, gro
|
||||
|
||||
await createMessage(_identifier, groupId, message, userParticipants);
|
||||
|
||||
emitNet(events.MESSAGES_SEND_MESSAGE_SUCCESS, _source, groupId);
|
||||
emitNet(MessageEvents.SEND_MESSAGE_SUCCESS, _source, groupId);
|
||||
|
||||
// gets the identifiers foe the participants for current groupId.
|
||||
|
||||
@@ -520,8 +504,8 @@ onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, gro
|
||||
if (!participantPlayer) {
|
||||
return;
|
||||
}
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, participantPlayer.source);
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, participantPlayer.source);
|
||||
emitNet(MessageEvents.CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
|
||||
groupName,
|
||||
groupId,
|
||||
message,
|
||||
@@ -531,11 +515,11 @@ onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, gro
|
||||
} catch (e) {
|
||||
// Not really sure what this does? As I cant find any reference
|
||||
// of this in the ui part.
|
||||
emitNet(events.MESSAGES_SEND_MESSAGE_FAILED, _source);
|
||||
emitNet(MessageEvents.SEND_MESSAGE_FAILED, _source);
|
||||
// sending a new alert
|
||||
// The message property is always using the locale strings without
|
||||
// the APPS_ prefix.
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
emitNet(MessageEvents.ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_NEW_MESSAGE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
@@ -545,12 +529,12 @@ onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, gro
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_SET_MESSAGE_READ, async (groupId: string) => {
|
||||
onNet(MessageEvents.SET_MESSAGE_READ, async (groupId: string) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(pSource);
|
||||
await setMessageRead(groupId, identifier);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, pSource);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS, pSource);
|
||||
} catch (e) {
|
||||
messageLogger.error(`Failed to set message as read, ${e.message}`, {
|
||||
source: pSource,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import events from '../utils/events';
|
||||
import { pool } from './db';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { Note, NoteId } from '../../typings/notes';
|
||||
import { Note, NoteId, NotesEvents } from '../../typings/notes';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
const notesLogger = mainLogger.child({ module: 'notes' });
|
||||
@@ -27,13 +26,13 @@ async function updateNote(note: Note, identifier: string): Promise<any> {
|
||||
await pool.query(query, [note.title, note.content, note.id, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||
onNet(NotesEvents.ADD_NOTE, async (note: Note) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await addNote(_identifier, note);
|
||||
emitNet(events.NOTE_SEND_NOTE_SUCCESS, pSource);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.SEND_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_ADD_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -41,19 +40,19 @@ onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||
notesLogger.error(`Failed to add note ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_ADD_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||
onNet(NotesEvents.FETCH_ALL_NOTES, async () => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
const notes = await fetchAllNotes(_identifier);
|
||||
emitNet(events.NOTE_SEND_NOTE, pSource, notes);
|
||||
emitNet(NotesEvents.SEND_NOTE, pSource, notes);
|
||||
} catch (e) {
|
||||
notesLogger.error(`Failed to fetch notes ${e.message}`, {
|
||||
source: pSource,
|
||||
@@ -61,45 +60,45 @@ onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
||||
onNet(NotesEvents.DELETE_NOTE, async (noteId: NoteId) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await deleteNote(noteId.id, _identifier);
|
||||
|
||||
emitNet(events.NOTE_DELETE_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.DELETE_NOTE_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, 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(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_DELETE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||
onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await updateNote(note, _identifier);
|
||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.UPDATE_NOTE_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_UPDATE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, pSource);
|
||||
emitNet(NotesEvents.UPDATE_NOTE_FAILURE, pSource);
|
||||
notesLogger.error(`Failed to update note, ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_UPDATE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import events from '../utils/events';
|
||||
import { pool } from './db';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { IPhoto } from '../../typings/photo';
|
||||
import { IPhoto, PhotoEvents } from '../../typings/photo';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
const photoLogger = mainLogger.child({ module: 'photo' });
|
||||
@@ -22,12 +21,12 @@ async function deletePhoto(photo: IPhoto, identifier: string) {
|
||||
await pool.query(query, [photo.image, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||
onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
await uploadPhoto(identifier, image);
|
||||
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, _source);
|
||||
emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to upload photo, ${e.message}`, {
|
||||
source: _source,
|
||||
@@ -35,12 +34,12 @@ onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||
onNet(PhotoEvents.FETCH_PHOTOS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
const photos = await getPhotosByIdentifier(identifier);
|
||||
emitNet(events.CAMERA_SEND_PHOTOS, _source, photos);
|
||||
emitNet(PhotoEvents.SEND_PHOTOS, _source, photos);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
|
||||
source: _source,
|
||||
@@ -48,12 +47,12 @@ onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||
onNet(PhotoEvents.DELETE_PHOTO, async (photo: IPhoto) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
await deletePhoto(photo, identifier);
|
||||
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, _source);
|
||||
emitNet(PhotoEvents.DELETE_PHOTO_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
|
||||
source: _source,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import events from '../utils/events';
|
||||
import { getIdentifier, getPlayer, getSource } from './functions';
|
||||
import { ESX } from './server';
|
||||
import { pool } from './db';
|
||||
import { mainLogger } from './sv_logger';
|
||||
import { MarketplaceListing } from '../../typings/marketplace';
|
||||
import { reportListingToDiscord } from './discord';
|
||||
import { MarketplaceEvents } from '../../typings/marketplace';
|
||||
|
||||
const selloutLogger = mainLogger.child({ module: 'sellout' });
|
||||
|
||||
@@ -62,11 +61,11 @@ async function doesReportExist(listingId: number, profile: string): Promise<bool
|
||||
return result.length > 0;
|
||||
}
|
||||
|
||||
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||
onNet(MarketplaceEvents.FETCH_LISTING, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const listings = await fetchAllListings();
|
||||
emitNet(events.SELLOUT_SEND_LISTING, _source, listings);
|
||||
emitNet(MarketplaceEvents.SEND_LISTING, _source, listings);
|
||||
} catch (e) {
|
||||
selloutLogger.error(`Failed to fetch listings, ${e.message}`, {
|
||||
source: _source,
|
||||
@@ -74,7 +73,7 @@ onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||
onNet(MarketplaceEvents.ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const player = getPlayer(_source);
|
||||
@@ -88,8 +87,8 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||
listing,
|
||||
);
|
||||
|
||||
emitNet(events.SELLOUT_ADD_LISTING_SUCCESS, _source);
|
||||
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
||||
emitNet(MarketplaceEvents.ADD_LISTING_SUCCESS, _source);
|
||||
emitNet(MarketplaceEvents.ACTION_RESULT, _source, {
|
||||
message: 'MARKETPLACE_CREATE_LISTING_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -98,14 +97,14 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||
source: _source,
|
||||
});
|
||||
|
||||
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
||||
emitNet(MarketplaceEvents.ACTION_RESULT, _source, {
|
||||
message: 'MARKETPLACE_CREATE_LISTING_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_DELETE_LISTING, async (listingId: number) => {
|
||||
onNet(MarketplaceEvents.DELETE_LISTING, async (listingId: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(pSource);
|
||||
@@ -113,9 +112,9 @@ onNet(events.SELLOUT_DELETE_LISTING, async (listingId: number) => {
|
||||
await deleteListing(listingId, identifier);
|
||||
|
||||
// fetches the listings again
|
||||
emitNet(events.SELLOUT_DELETE_LISTING_SUCCESS, pSource);
|
||||
emitNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||
emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
|
||||
message: 'MARKETPLACE_DELETE_LISTING_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -123,14 +122,14 @@ onNet(events.SELLOUT_DELETE_LISTING, async (listingId: number) => {
|
||||
selloutLogger.error(`Failed to delete listing ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||
emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
|
||||
message: 'MARKETPLACE_DELETE_LISTING_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
|
||||
onNet(MarketplaceEvents.REPORT_LISTING, async (listing: MarketplaceListing) => {
|
||||
const pSource = getSource();
|
||||
|
||||
try {
|
||||
@@ -142,7 +141,7 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
|
||||
if (reportExists) {
|
||||
// send an info alert
|
||||
selloutLogger.error(`This listing has already been reported`);
|
||||
return emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||
return emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
|
||||
message: 'MARKETPLACE_REPORT_LISTING_FAILED',
|
||||
type: 'info',
|
||||
});
|
||||
@@ -151,7 +150,7 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
|
||||
await reportListing(rListing.id, rListing.name);
|
||||
await reportListingToDiscord(rListing, reportingPlayer);
|
||||
|
||||
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||
emitNet(MarketplaceEvents.ACTION_RESULT, pSource, {
|
||||
message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { ResultSetHeader } from 'mysql2';
|
||||
|
||||
import { pool } from './db';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { NewTweet, Tweet, Profile } from '../../typings/twitter';
|
||||
import events from '../utils/events';
|
||||
import config from '../utils/config';
|
||||
import { reportTweetToDiscord } from './discord';
|
||||
import { mainLogger } from './sv_logger';
|
||||
import { generateProfileName, getDefaultProfileNames } from './players/sv_players';
|
||||
import { TwitterEvents } from '../../typings/twitter';
|
||||
|
||||
const twitterLogger = mainLogger.child({ module: 'twitter' });
|
||||
|
||||
@@ -310,36 +309,35 @@ async function doesRetweetExist(tweetId: number, identifier: string): Promise<bo
|
||||
return counts[0].count > 0;
|
||||
}
|
||||
|
||||
onNet(events.TWITTER_GET_OR_CREATE_PROFILE, async () => {
|
||||
onNet(TwitterEvents.GET_OR_CREATE_PROFILE, async () => {
|
||||
const _source = getSource();
|
||||
const identifier = 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(events.TWITTER_GET_OR_CREATE_PROFILE_NULL, _source, defaultProfileNames);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_NULL, _source, defaultProfileNames);
|
||||
} else {
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_SUCCESS, _source, profile);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_SUCCESS, _source, profile);
|
||||
}
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Failed to get or create profile, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_FAILURE, _source);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_PROFILE, async (profile: Profile) => {
|
||||
onNet(TwitterEvents.CREATE_PROFILE, async (profile: Profile) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
await createProfile(identifier, profile.profile_name);
|
||||
emitNet(events.TWITTER_CREATE_PROFILE_RESULT, _source, {
|
||||
emitNet(TwitterEvents.CREATE_PROFILE_RESULT, _source, {
|
||||
message: 'TWITTER_CREATE_PROFILE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -347,19 +345,19 @@ onNet(events.TWITTER_CREATE_PROFILE, async (profile: Profile) => {
|
||||
twitterLogger.error(`Failed to create twitter profile: ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_CREATE_PROFILE_RESULT, _source, {
|
||||
emitNet(TwitterEvents.CREATE_PROFILE_RESULT, _source, {
|
||||
message: 'TWITTER_CREATE_PROFILE_FAILURE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_UPDATE_PROFILE, async (profile: Profile) => {
|
||||
onNet(TwitterEvents.UPDATE_PROFILE, async (profile: Profile) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
await updateProfile(identifier, profile);
|
||||
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, _source, {
|
||||
emitNet(TwitterEvents.UPDATE_PROFILE_RESULT, _source, {
|
||||
message: 'TWITTER_EDIT_PROFILE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -367,14 +365,14 @@ onNet(events.TWITTER_UPDATE_PROFILE, async (profile: Profile) => {
|
||||
twitterLogger.error(`Failed to update twitter profile: ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, _source, {
|
||||
emitNet(TwitterEvents.UPDATE_PROFILE_RESULT, _source, {
|
||||
message: 'TWITTER_EDIT_PROFILE_FAILURE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS, async () => {
|
||||
onNet(TwitterEvents.FETCH_TWEETS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
@@ -387,63 +385,63 @@ onNet(events.TWITTER_FETCH_TWEETS, async () => {
|
||||
}
|
||||
|
||||
const tweets = await fetchAllTweets(profile.id);
|
||||
emitNet(events.TWITTER_FETCH_TWEETS_SUCCESS, _source, tweets);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS_SUCCESS, _source, tweets);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Fetching tweets failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_FETCH_TWEETS_FAILURE, _source);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_FETCH_TWEETS_FILTERED, async (searchValue: string) => {
|
||||
onNet(TwitterEvents.FETCH_TWEETS_FILTERED, async (searchValue: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
const profile = await getProfile(identifier);
|
||||
const tweets = await fetchTweetsFiltered(profile.id, searchValue);
|
||||
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_SUCCESS, _source, tweets);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS_FILTERED_SUCCESS, _source, tweets);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Fetch filtered tweets failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_FAILURE, _source);
|
||||
emitNet(TwitterEvents.FETCH_TWEETS_FILTERED_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_CREATE_TWEET, async (tweet: Tweet) => {
|
||||
onNet(TwitterEvents.CREATE_TWEET, async (tweet: Tweet) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
const createdTweet = await createTweet(identifier, tweet);
|
||||
emitNet(events.TWITTER_CREATE_TWEET_BROADCAST, -1, createdTweet);
|
||||
emitNet(TwitterEvents.CREATE_TWEET_BROADCAST, -1, createdTweet);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Create tweet failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_CREATE_TWEET_RESULT, _source, {
|
||||
emitNet(TwitterEvents.CREATE_TWEET_RESULT, _source, {
|
||||
message: 'TWITTER_CREATE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_DELETE_TWEET, async (tweetId: number) => {
|
||||
onNet(TwitterEvents.DELETE_TWEET, async (tweetId: number) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
await deleteTweet(identifier, tweetId);
|
||||
|
||||
emitNet(events.TWITTER_DELETE_TWEET_SUCCESS, _source);
|
||||
emitNet(TwitterEvents.DELETE_TWEET_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Delete tweet failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_DELETE_TWEET_FAILURE, _source);
|
||||
emitNet(TwitterEvents.DELETE_TWEET_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_TOGGLE_LIKE, async (tweetId: number) => {
|
||||
onNet(TwitterEvents.TOGGLE_LIKE, async (tweetId: number) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
@@ -454,16 +452,16 @@ onNet(events.TWITTER_TOGGLE_LIKE, async (tweetId: number) => {
|
||||
} else {
|
||||
await createLike(profile.id, tweetId);
|
||||
}
|
||||
emitNet(events.TWITTER_TOGGLE_LIKE_SUCCESS, _source);
|
||||
emitNet(TwitterEvents.TOGGLE_LIKE_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Like failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_TOGGLE_LIKE_FAILURE, _source);
|
||||
emitNet(TwitterEvents.TOGGLE_LIKE_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_RETWEET, async (tweetId: number) => {
|
||||
onNet(TwitterEvents.RETWEET, async (tweetId: number) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
@@ -471,7 +469,7 @@ onNet(events.TWITTER_RETWEET, async (tweetId: number) => {
|
||||
// alert the player that they have already retweeted
|
||||
// this post (or that they are the original poster)
|
||||
if (await doesRetweetExist(tweetId, identifier)) {
|
||||
return emitNet(events.TWITTER_RETWEET_EXISTS, _source, {
|
||||
return emitNet(TwitterEvents.RETWEET_EXISTS, _source, {
|
||||
message: 'TWITTER_RETWEET_EXISTS',
|
||||
type: 'error',
|
||||
});
|
||||
@@ -485,16 +483,16 @@ onNet(events.TWITTER_RETWEET, async (tweetId: number) => {
|
||||
|
||||
const profile = await getProfile(identifier);
|
||||
const tweet = await getTweet(profile.id, createdTweet.id);
|
||||
emitNet(events.TWITTER_CREATE_TWEET_BROADCAST, -1, tweet);
|
||||
emitNet(TwitterEvents.CREATE_TWEET_BROADCAST, -1, tweet);
|
||||
} catch (e) {
|
||||
twitterLogger.error(`Retweet failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.TWITTER_RETWEET_FAILURE, _source);
|
||||
emitNet(TwitterEvents.RETWEET_FAILURE, _source);
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.TWITTER_REPORT, async (tweetId: number) => {
|
||||
onNet(TwitterEvents.REPORT, async (tweetId: number) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const identifier = getIdentifier(_source);
|
||||
@@ -510,9 +508,9 @@ onNet(events.TWITTER_REPORT, async (tweetId: number) => {
|
||||
await createTweetReport(tweet.id, profile.id);
|
||||
await reportTweetToDiscord(tweet, profile);
|
||||
|
||||
emitNet(events.TWITTER_REPORT_SUCCESS, _source);
|
||||
emitNet(TwitterEvents.REPORT_SUCCESS, _source);
|
||||
} catch (e) {
|
||||
emitNet(events.TWITTER_REPORT_FAILURE, _source);
|
||||
emitNet(TwitterEvents.REPORT_FAILURE, _source);
|
||||
twitterLogger.error(`Twitter report failed, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
export default {
|
||||
// Twitter
|
||||
TWITTER_FETCH_TWEETS: 'phone:fetchTweets',
|
||||
TWITTER_FETCH_TWEETS_SUCCESS: 'fetchTweets',
|
||||
TWITTER_FETCH_TWEETS_FAILURE: 'fetchTweetsFailed',
|
||||
TWITTER_FETCH_TWEETS_FILTERED: 'phone:fetchTweetsFiltered',
|
||||
TWITTER_FETCH_TWEETS_FILTERED_SUCCESS: 'fetchTweetsFiltered',
|
||||
TWITTER_FETCH_TWEETS_FILTERED_FAILURE: 'fetchTweetsFilteredFailed',
|
||||
TWITTER_GET_OR_CREATE_PROFILE: 'phone:getOrCreateTwitterProfile',
|
||||
TWITTER_GET_OR_CREATE_PROFILE_SUCCESS: 'getOrCreateTwitterProfile',
|
||||
TWITTER_GET_OR_CREATE_PROFILE_NULL: 'getOrCreateTwitterProfileNull',
|
||||
TWITTER_GET_OR_CREATE_PROFILE_FAILURE: 'getOrCreateTwitterProfileFailed',
|
||||
TWITTER_CREATE_PROFILE: 'phone:createTwitterProfile',
|
||||
TWITTER_CREATE_PROFILE_RESULT: 'phone:createProfileResult',
|
||||
TWITTER_UPDATE_PROFILE: 'phone:updateTwitterProfile',
|
||||
TWITTER_UPDATE_PROFILE_LOADING: 'updateProfileLoading',
|
||||
TWITTER_UPDATE_PROFILE_RESULT: 'updateProfileResult',
|
||||
TWITTER_CREATE_TWEET: 'phone:createTweet',
|
||||
TWITTER_CREATE_TWEET_LOADING: 'createTweetLoading',
|
||||
TWITTER_CREATE_TWEET_RESULT: 'createTweetResult',
|
||||
TWITTER_CREATE_TWEET_BROADCAST: 'createTweetBroadcast',
|
||||
TWITTER_CREATE_TWEET_FAILURE: 'createTweetResultFailed',
|
||||
TWITTER_DELETE_TWEET: 'phone:deleteTweet',
|
||||
TWITTER_DELETE_TWEET_SUCCESS: 'deleteTweetSuccess',
|
||||
TWITTER_DELETE_TWEET_FAILURE: 'deleteTweetFailed',
|
||||
TWITTER_TOGGLE_LIKE: 'phone:toggleLike',
|
||||
TWITTER_TOGGLE_LIKE_SUCCESS: 'toggleLikeSuccess',
|
||||
TWITTER_TOGGLE_LIKE_FAILURE: 'toggleLikeFailed',
|
||||
TWITTER_RETWEET: 'phone:retweet',
|
||||
TWITTER_RETWEET_SUCCESS: 'phone:retweetSuccess',
|
||||
TWITTER_RETWEET_EXISTS: 'phone:retweetExists',
|
||||
TWITTER_RETWEET_FAILURE: 'phone:retweetFailed',
|
||||
TWITTER_REPORT: 'phone:reportTweet',
|
||||
TWITTER_REPORT_SUCCESS: 'reportTweetSuccess',
|
||||
TWITTER_REPORT_FAILURE: 'reportTweetFailed',
|
||||
|
||||
// Contacts
|
||||
CONTACTS_SEND_CONTACTS: 'phone:sendContacts',
|
||||
CONTACTS_GET_CONTACTS: 'phone:getContacts',
|
||||
CONTACTS_ADD_CONTACT_NUI: 'contacts:add',
|
||||
CONTACTS_ADD_CONTACT: 'phone:addContacts',
|
||||
CONTACTS_ADD_CONTACT_SUCCESS: 'contacts:addSuccess',
|
||||
CONTACTS_UPDATE_CONTACT: 'phone:updateContact',
|
||||
CONTACTS_DELETE_CONTACT: 'phone:deleteContact',
|
||||
CONTACTS_DELETE_CONTACT_SUCCESS: 'contacts:deleteSuccess',
|
||||
CONTACTS_UPDATE_CONTACT_SUCCESS: 'phone:updateContactSuccess',
|
||||
CONTACTS_ACTION_RESULT: 'phone:contactActionResult',
|
||||
|
||||
// Sellout
|
||||
// these event keys needs to be changed to 'MARKETPLACE'
|
||||
SELLOUT_ADD_LISTING: 'phone:addListing',
|
||||
SELLOUT_ADD_LISTING_SUCCESS: 'phone:addListingSuccess',
|
||||
SELLOUT_FETCH_LISTING: 'phone:fetchAllListings',
|
||||
SELLOUT_SEND_LISTING: 'phone:sendAllListings',
|
||||
SELLOUT_ACTION_RESULT: 'phone:selloutActionResult',
|
||||
SELLOUT_DELETE_LISTING: 'phone:marketplaceDeleteListing',
|
||||
SELLOUT_DELETE_LISTING_SUCCESS: 'phone:marketplaceDeleteListingSuccess',
|
||||
SELLOUT_REPORT_LISTING: 'phone:reportListing',
|
||||
SELLOUT_REPORT_LISTING_SUCCESS: 'phone:reportListingSuccess',
|
||||
SELLOUT_REPORT_LISTING_SUCESS: 'phone:reportListingFailed',
|
||||
|
||||
//
|
||||
BANK_ADD_TRANSFER: 'phone:addTransfer',
|
||||
BANK_ADD_TRANSFER_SUCCESS: 'phone:addTransferSuccess',
|
||||
BANK_FETCH_TRANSACTIONS: 'phone:fetchAllTransactions',
|
||||
BANK_SEND_TRANSFERS: 'phone:sendTransfers',
|
||||
BANK_TRANSACTION_ALERT: 'phone:bankTransactionAlert',
|
||||
BANK_TRANSACTION_NOTIFICATION: 'phone:bankTransactionNotification',
|
||||
BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials',
|
||||
BANK_GET_CREDENTIALS: 'phone:getBankCredentials',
|
||||
|
||||
//messages
|
||||
MESSAGES_FETCH_MESSAGE_GROUPS: 'phone:fetchMessageGroups',
|
||||
MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS: 'phone:fetchMessageGroupsSuccess',
|
||||
MESSAGES_FETCH_MESSAGE_GROUPS_FAILED: 'phone:fetchMessageGroupsFailed',
|
||||
MESSAGES_CREATE_MESSAGE_GROUP: 'phone:createMessageGroup',
|
||||
MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS: 'phone:createMessageGroupSuccess',
|
||||
MESSAGES_CREATE_MESSAGE_GROUP_FAILED: 'phone:createMessageGroupFailed',
|
||||
MESSAGES_SEND_MESSAGE: 'phone:sendMessage',
|
||||
MESSAGES_SEND_MESSAGE_SUCCESS: 'phone:sendMessageSuccess',
|
||||
MESSAGES_SEND_MESSAGE_FAILED: 'phone:sendMessageFailed',
|
||||
MESSAGES_FETCH_MESSAGES: 'phone:fetchMessages',
|
||||
MESSAGES_FETCH_MESSAGES_SUCCESS: 'phone:fetchMessagesSuccess',
|
||||
MESSAGES_FETCH_MESSAGES_FAILED: 'phone:fetchMessagesFailed',
|
||||
MESSAGES_ACTION_RESULT: 'phone:setMessagesAlert',
|
||||
MESSAGES_CREATE_MESSAGE_BROADCAST: 'createMessagesBroadcast',
|
||||
MESSAGES_SET_MESSAGE_READ: 'phone:setReadMessages',
|
||||
|
||||
// Notes
|
||||
NOTE_ADD_NOTE: 'phone:addNote',
|
||||
NOTE_FETCH_ALL_NOTES: 'phone:fetchAllNotes',
|
||||
NOTE_SEND_NOTE: 'phone:sendNote',
|
||||
NOTE_SEND_NOTE_SUCCESS: 'phone:sendNoteSuccess',
|
||||
NOTE_DELETE_NOTE: 'phone:deleteNote',
|
||||
NOTE_DELETE_NOTE_SUCCESS: 'phone:deleteNoteSuccess',
|
||||
NOTE_UPDATE_NOTE: 'phone:updateNote',
|
||||
NOTE_UPDATE_NOTE_SUCCESS: 'phone:updateNoteSuccess',
|
||||
NOTE_UPDATE_NOTE_FAILURE: 'phone:updateNoteFailure',
|
||||
NOTE_ACTION_RESULT: 'phone:notesActionResult',
|
||||
|
||||
// DO NOT CHANGE WHATS BELOW, PLEASE - CHIP
|
||||
PLAYER_IS_READY: 'phone:playerIsReady',
|
||||
OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
|
||||
OPEN_APP_BANK: 'phone:app:BANK',
|
||||
OPEN_APP_NOTES: 'phone:app:NOTES',
|
||||
OPEN_APP_LISTINGS: 'phone:app:SELLOUT',
|
||||
OPEN_APP_CAMERA: 'phone:app:CAMERA',
|
||||
OPEN_APP_DAILER: 'phone:app:DIALER',
|
||||
|
||||
// camera
|
||||
CAMERA_TAKE_PHOTO: 'phone:TakePhoto',
|
||||
CAMERA_UPLOAD_PHOTO: 'phone:UploadPhoto',
|
||||
CAMERA_UPLOAD_PHOTO_SUCCESS: 'phone:UploadPhotoSuccess',
|
||||
CAMERA_FETCH_PHOTOS: 'phone:FetchPhotos',
|
||||
CAMERA_SEND_PHOTOS: 'phone:SendPhotos',
|
||||
CAMERA_DELETE_PHOTO: 'photo:deletePhoto',
|
||||
CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess',
|
||||
// copy
|
||||
PHONE_USE_CLIPBOARD: 'phone:useClipboard',
|
||||
|
||||
// calling
|
||||
PHONE_INITIALIZE_CALL: 'phone:beginCall',
|
||||
PHONE_START_CALL: 'phone:startCall',
|
||||
PHONE_ACCEPT_CALL: 'phone:acceptCall',
|
||||
PHONE_END_CALL: 'phone:endCall',
|
||||
PHONE_CALL_WAS_ENDED: 'phone:callEnded',
|
||||
PHONE_CALL_WAS_ACCEPTED: 'phone:callAccepted',
|
||||
PHONE_CALL_REJECTED: 'phone:rejectCall',
|
||||
PHONE_CALL_WAS_REJECTED: 'phone:callRejected',
|
||||
PHONE_CALL_FETCH_CALLS: 'phone:fetchCalls',
|
||||
PHONE_CALL_SEND_HISTORY: 'phone:sendCallHistory',
|
||||
PHONE_CALL_SEND_HANGUP_ANIM: 'phone:sendHangupAnim',
|
||||
};
|
||||
@@ -17,3 +17,14 @@ export interface ITransactions {
|
||||
type: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export enum BankEvents {
|
||||
ADD_TRANSFER = 'npwd:addTransfer',
|
||||
ADD_TRANSFER_SUCCESS = 'npwd:addTransferSuccess',
|
||||
FETCH_TRANSACTIONS = 'npwd:fetchAllTransactions',
|
||||
SEND_TRANSFERS = 'npwd:sendTransfers',
|
||||
TRANSACTION_ALERT = 'npwd:bankTransactionAlert',
|
||||
TRANSACTION_NOTIFICATION = 'npwd:bankTransactionNotification',
|
||||
SEND_CREDENTIALS = 'npwd:sendBankCredentials',
|
||||
GET_CREDENTIALS = 'npwd:getBankCredentials',
|
||||
}
|
||||
@@ -24,3 +24,17 @@ export interface ICallDuration {
|
||||
m: number;
|
||||
h: number;
|
||||
}
|
||||
|
||||
export enum CallEvents {
|
||||
INITIALIZE_CALL = 'npwd:beginCall',
|
||||
START_CALL = 'npwd:startCall',
|
||||
ACCEPT_CALL = 'npwd:acceptCall',
|
||||
END_CALL = 'npwd:endCall',
|
||||
WAS_ENDED = 'npwd:callEnded',
|
||||
WAS_ACCEPTED = 'npwd:callAccepted',
|
||||
REJECTED = 'npwd:rejectCall',
|
||||
WAS_REJECTED = 'npwd:callRejected',
|
||||
FETCH_CALLS = 'npwd:fetchCalls',
|
||||
SEND_HISTORY = 'npwd:sendCallHistory',
|
||||
SEND_HANGUP_ANIM = 'npwd:sendHangupAnim',
|
||||
}
|
||||
@@ -17,3 +17,15 @@ export interface Contact {
|
||||
number: string;
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
export enum ContactEvents {
|
||||
SEND_CONTACTS = 'npwd:sendContacts',
|
||||
GET_CONTACTS = 'npwd:getContacts',
|
||||
ADD_CONTACT = 'npwd:addContacts',
|
||||
ADD_CONTACT_SUCCESS = 'contacts:addSuccess',
|
||||
UPDATE_CONTACT = 'npwd:updateContact',
|
||||
DELETE_CONTACT = 'npwd:deleteContact',
|
||||
DELETE_CONTACT_SUCCESS = 'npwd:deleteSuccess',
|
||||
UPDATE_CONTACT_SUCCESS = 'npwd:updateContactSuccess',
|
||||
ACTION_RESULT = 'npwd:contactActionResult',
|
||||
}
|
||||
@@ -8,3 +8,16 @@ export interface MarketplaceListing {
|
||||
url: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export enum MarketplaceEvents {
|
||||
ADD_LISTING = 'npwd:addListing',
|
||||
ADD_LISTING_SUCCESS = 'npwd:addListingSuccess',
|
||||
FETCH_LISTING = 'npwd:fetchAllListings',
|
||||
SEND_LISTING = 'npwd:sendAllListings',
|
||||
ACTION_RESULT = 'npwd:selloutActionResult',
|
||||
DELETE_LISTING = 'npwd:marketplaceDeleteListing',
|
||||
DELETE_LISTING_SUCCESS = 'npwd:marketplaceDeleteListingSuccess',
|
||||
REPORT_LISTING = 'npwd:reportListing',
|
||||
REPORT_LISTING_SUCCESS = 'npwd:reportListingSuccess',
|
||||
REPORT_LISTING_SUCESS = 'npwd:reportListingFailed',
|
||||
}
|
||||
@@ -41,3 +41,21 @@ export interface CreateMessageBroadcast {
|
||||
export interface SetMessageRead {
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
export enum MessageEvents {
|
||||
FETCH_MESSAGE_GROUPS = 'npwd:fetchMessageGroups',
|
||||
FETCH_MESSAGE_GROUPS_SUCCESS = 'npwd:fetchMessageGroupsSuccess',
|
||||
FETCH_MESSAGE_GROUPS_FAILED = 'npwd:fetchMessageGroupsFailed',
|
||||
CREATE_MESSAGE_GROUP = 'npwd:createMessageGroup',
|
||||
CREATE_MESSAGE_GROUP_SUCCESS = 'npwd:createMessageGroupSuccess',
|
||||
CREATE_MESSAGE_GROUP_FAILED = 'npwd:createMessageGroupFailed',
|
||||
SEND_MESSAGE = 'npwd:sendMessage',
|
||||
SEND_MESSAGE_SUCCESS = 'npwd:sendMessageSuccess',
|
||||
SEND_MESSAGE_FAILED = 'npwd:sendMessageFailed',
|
||||
FETCH_MESSAGES = 'npwd:fetchMessages',
|
||||
FETCH_MESSAGES_SUCCESS = 'npwd:fetchMessagesSuccess',
|
||||
FETCH_MESSAGES_FAILED = 'npwd:fetchMessagesFailed',
|
||||
ACTION_RESULT = 'npwd:setMessagesAlert',
|
||||
CREATE_MESSAGE_BROADCAST = 'createMessagesBroadcast',
|
||||
SET_MESSAGE_READ = 'npwd:setReadMessages',
|
||||
}
|
||||
@@ -20,3 +20,16 @@ export interface Note {
|
||||
export interface NoteId {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export enum NotesEvents {
|
||||
ADD_NOTE = 'npwd:addNote',
|
||||
FETCH_ALL_NOTES = 'npwd:fetchAllNotes',
|
||||
SEND_NOTE = 'npwd:sendNote',
|
||||
SEND_NOTE_SUCCESS = 'npwd:sendNoteSuccess',
|
||||
DELETE_NOTE = 'npwd:deleteNote',
|
||||
DELETE_NOTE_SUCCESS = 'npwd:deleteNoteSuccess',
|
||||
UPDATE_NOTE = 'npwd:updateNote',
|
||||
UPDATE_NOTE_SUCCESS = 'npwd:updateNoteSuccess',
|
||||
UPDATE_NOTE_FAILURE = 'npwd:updateNoteFailure',
|
||||
ACTION_RESULT = 'npwd:notesActionResult',
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export enum PhoneEvents {
|
||||
PLAYER_IS_READY = 'npwd:playerIsReady',
|
||||
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_CAMERA = 'npwd:app:CAMERA',
|
||||
OPEN_APP_DAILER = 'npwd:app:DIALER',
|
||||
OPEN_PHONE = 'npwd:open',
|
||||
CLOSE_PHONE = 'npwd:close',
|
||||
}
|
||||
@@ -2,3 +2,13 @@ export interface IPhoto {
|
||||
image: string;
|
||||
id: number;
|
||||
}
|
||||
|
||||
export enum PhotoEvents {
|
||||
TAKE_PHOTO = 'npwd:TakePhoto',
|
||||
UPLOAD_PHOTO = 'npwd:UploadPhoto',
|
||||
UPLOAD_PHOTO_SUCCESS = 'npwd:UploadPhotoSuccess',
|
||||
FETCH_PHOTOS = 'npwd:FetchPhotos',
|
||||
SEND_PHOTOS = 'npwd:SendPhotos',
|
||||
DELETE_PHOTO = 'npwd:deletePhoto',
|
||||
DELETE_PHOTO_SUCCESS = 'npwd:deletePhotoSuccess',
|
||||
}
|
||||
@@ -46,3 +46,39 @@ export interface Profile {
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export enum TwitterEvents {
|
||||
FETCH_TWEETS = 'npwd:fetchTweets',
|
||||
FETCH_TWEETS_SUCCESS = 'fetchTweets',
|
||||
FETCH_TWEETS_FAILURE = 'fetchTweetsFailed',
|
||||
FETCH_TWEETS_FILTERED = 'npwd:fetchTweetsFiltered',
|
||||
FETCH_TWEETS_FILTERED_SUCCESS = 'fetchTweetsFiltered',
|
||||
FETCH_TWEETS_FILTERED_FAILURE = 'fetchTweetsFilteredFailed',
|
||||
CREATE_PROFILE = 'npwd:createTwitterProfile',
|
||||
CREATE_PROFILE_RESULT = 'npwd:createProfileResult',
|
||||
GET_OR_CREATE_PROFILE = 'npwd:getOrCreateTwitterProfile',
|
||||
GET_OR_CREATE_PROFILE_NULL = 'getOrCreateTwitterProfileNull',
|
||||
GET_OR_CREATE_PROFILE_SUCCESS = 'getOrCreateTwitterProfile',
|
||||
GET_OR_CREATE_PROFILE_FAILURE = 'getOrCreateTwitterProfileFailed',
|
||||
UPDATE_PROFILE = 'npwd:updateTwitterProfile',
|
||||
UPDATE_PROFILE_LOADING = 'updateProfileLoading',
|
||||
UPDATE_PROFILE_RESULT = 'updateProfileResult',
|
||||
CREATE_TWEET = 'npwd:createTweet',
|
||||
CREATE_TWEET_LOADING = 'createTweetLoading',
|
||||
CREATE_TWEET_RESULT = 'createTweetResult',
|
||||
CREATE_TWEET_BROADCAST = 'createTweetBroadcast',
|
||||
CREATE_TWEET_FAILURE = 'createTweetResultFailed',
|
||||
DELETE_TWEET = 'npwd:deleteTweet',
|
||||
DELETE_TWEET_SUCCESS = 'deleteTweetSuccess',
|
||||
DELETE_TWEET_FAILURE = 'deleteTweetFailed',
|
||||
TOGGLE_LIKE = 'npwd:toggleLike',
|
||||
TOGGLE_LIKE_SUCCESS = 'toggleLikeSuccess',
|
||||
TOGGLE_LIKE_FAILURE = 'toggleLikeFailed',
|
||||
RETWEET = 'npwd:retweet',
|
||||
RETWEET_SUCCESS = 'npwd:retweetSuccess',
|
||||
RETWEET_EXISTS = 'npwd:retweetExists',
|
||||
RETWEET_FAILURE = 'npwd:retweetFailed',
|
||||
REPORT = 'npwd:reportTweet',
|
||||
REPORT_SUCCESS = 'reportTweetSuccess',
|
||||
REPORT_FAILURE = 'reportTweetFailed',
|
||||
}
|
||||
Reference in new issue
Block a user