mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Create what?
Renamed create function to createReporter function
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
|||||||
findPonies, removeCharactersAboveLimit, createCharacter, removeCharacter, assignCharacter, removeAllCharacters
|
findPonies, removeCharactersAboveLimit, createCharacter, removeCharacter, assignCharacter, removeAllCharacters
|
||||||
} from './api/ponies';
|
} from './api/ponies';
|
||||||
import { accountStatus, accountAround, getServer, getLoginServer, RemovedDocument, accountHidden } from './internal';
|
import { accountStatus, accountAround, getServer, getLoginServer, RemovedDocument, accountHidden } from './internal';
|
||||||
import { create } from './reporter';
|
import { createReporter } from './reporter';
|
||||||
import { system } from './logger';
|
import { system } from './logger';
|
||||||
import { AdminService } from './services/adminService';
|
import { AdminService } from './services/adminService';
|
||||||
import { getOriginStats, clearOrigins, removeAllOrigins, removeOrigins, addOrigin, clearOriginsForAccounts } from './api/origins';
|
import { getOriginStats, clearOrigins, removeAllOrigins, removeOrigins, addOrigin, clearOriginsForAccounts } from './api/origins';
|
||||||
@@ -185,7 +185,7 @@ export class AdminServerActions implements IAdminServerActions, SocketServer {
|
|||||||
}
|
}
|
||||||
@Method({ promise: true })
|
@Method({ promise: true })
|
||||||
async report(accountId: string) {
|
async report(accountId: string) {
|
||||||
create(this.server, accountId).info(`Reported by ${this.account.name}`);
|
createReporter(this.server, accountId).info(`Reported by ${this.account.name}`);
|
||||||
}
|
}
|
||||||
@Method({ promise: true })
|
@Method({ promise: true })
|
||||||
async notifyUpdate(server: string) {
|
async notifyUpdate(server: string) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { World } from './world';
|
|||||||
import { centerCameraOn, createCamera } from '../common/camera';
|
import { centerCameraOn, createCamera } from '../common/camera';
|
||||||
import { findEntitiesInBounds } from './serverMap';
|
import { findEntitiesInBounds } from './serverMap';
|
||||||
import { CounterService } from './services/counter';
|
import { CounterService } from './services/counter';
|
||||||
import { create } from './reporter';
|
import { createReporter } from './reporter';
|
||||||
import { updateAccountState } from './accountUtils';
|
import { updateAccountState } from './accountUtils';
|
||||||
import { isMod } from '../common/accountUtils';
|
import { isMod } from '../common/accountUtils';
|
||||||
import { getOriginFromHTTP } from './originUtils';
|
import { getOriginFromHTTP } from './originUtils';
|
||||||
@@ -61,7 +61,7 @@ export function createClientAndPony(
|
|||||||
) {
|
) {
|
||||||
const { account, character } = client.tokenData as TokenData;
|
const { account, character } = client.tokenData as TokenData;
|
||||||
const origin = client.originalRequest && getOriginFromHTTP(client.originalRequest);
|
const origin = client.originalRequest && getOriginFromHTTP(client.originalRequest);
|
||||||
const reporter = create(server, account._id, character._id, origin);
|
const reporter = createReporter(server, account._id, character._id, origin);
|
||||||
const state = getAndFixCharacterState(server, character, world, states);
|
const state = getAndFixCharacterState(server, character, world, states);
|
||||||
|
|
||||||
client.characterState = state;
|
client.characterState = state;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const createLogEvent =
|
|||||||
const ignoreWarnings = ['Suspicious message', 'Spam'];
|
const ignoreWarnings = ['Suspicious message', 'Spam'];
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
export function create(server: ServerConfig, account?: ID, pony?: ID, originInfo?: IOriginInfo): Reporter {
|
export function createReporter(server: ServerConfig, account?: ID, pony?: ID, originInfo?: IOriginInfo): Reporter {
|
||||||
const logEvent = createLogEvent(server);
|
const logEvent = createLogEvent(server);
|
||||||
const accountId = `${account}`;
|
const accountId = `${account}`;
|
||||||
|
|
||||||
@@ -99,5 +99,5 @@ export function createFromRequest(server: ServerConfig, req: Request, pony?: any
|
|||||||
const user = req && req.user as IAccount | undefined;
|
const user = req && req.user as IAccount | undefined;
|
||||||
const account = user?._id?.toString();
|
const account = user?._id?.toString();
|
||||||
const origin = req ? getOrigin(req) : undefined;
|
const origin = req ? getOrigin(req) : undefined;
|
||||||
return create(server, account, pony, origin);
|
return createReporter(server, account, pony, origin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { BannedMuted, Settings, ServerConfig, AccountFlags, ServerLiveSettings }
|
|||||||
import { Account, IAccount, Origin, IOrigin } from '../db';
|
import { Account, IAccount, Origin, IOrigin } from '../db';
|
||||||
import { limit, auth as authRequest, wrap } from '../requestUtils';
|
import { limit, auth as authRequest, wrap } from '../requestUtils';
|
||||||
import { CreateAccountOptions, findOrCreateAccount, SuspiciousCheckers, getAccountAlertMessage } from '../accountUtils';
|
import { CreateAccountOptions, findOrCreateAccount, SuspiciousCheckers, getAccountAlertMessage } from '../accountUtils';
|
||||||
import { create, createFromRequest } from '../reporter';
|
import { createReporter, createFromRequest } from '../reporter';
|
||||||
import { logger, logServer, system } from '../logger';
|
import { logger, logServer, system } from '../logger';
|
||||||
import { providers, getProfile } from '../oauth';
|
import { providers, getProfile } from '../oauth';
|
||||||
import { accountChanged, RemovedDocument } from '../internal';
|
import { accountChanged, RemovedDocument } from '../internal';
|
||||||
@@ -120,7 +120,7 @@ async function checkBanField(
|
|||||||
server: ServerConfig, account: IAccount, field: keyof BannedMuted, message: string, origin: IOrigin
|
server: ServerConfig, account: IAccount, field: keyof BannedMuted, message: string, origin: IOrigin
|
||||||
) {
|
) {
|
||||||
if (isActive(origin[field]) && !isActive(account[field])) {
|
if (isActive(origin[field]) && !isActive(account[field])) {
|
||||||
create(server, account._id, undefined, origin).warn(message);
|
createReporter(server, account._id, undefined, origin).warn(message);
|
||||||
account[field] = origin[field];
|
account[field] = origin[field];
|
||||||
await account.save();
|
await account.save();
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ function createOptions(
|
|||||||
creationLocked: acl && acl > (new Date()).toISOString(),
|
creationLocked: acl && acl > (new Date()).toISOString(),
|
||||||
canCreateAccounts: !!settings.canCreateAccounts,
|
canCreateAccounts: !!settings.canCreateAccounts,
|
||||||
reportPotentialDuplicates: !!settings.reportPotentialDuplicates,
|
reportPotentialDuplicates: !!settings.reportPotentialDuplicates,
|
||||||
warn: (accountId, message, desc) => create(server, accountId, undefined, origin).warn(message, desc),
|
warn: (accountId, message, desc) => createReporter(server, accountId, undefined, origin).warn(message, desc),
|
||||||
...checkers,
|
...checkers,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import * as ctrl from './controllers';
|
import * as ctrl from './controllers';
|
||||||
import { World, goToMap } from './world';
|
import { World, goToMap } from './world';
|
||||||
import { create } from './reporter';
|
import { createReporter } from './reporter';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { SERVER_FPS } from '../common/constants';
|
import { SERVER_FPS } from '../common/constants';
|
||||||
import { ServerConfig } from '../common/adminInterfaces';
|
import { ServerConfig } from '../common/adminInterfaces';
|
||||||
@@ -77,7 +77,7 @@ export function start(world: World, server: ServerConfig) {
|
|||||||
world.initialize(last);
|
world.initialize(last);
|
||||||
|
|
||||||
if (!DEVELOPMENT) {
|
if (!DEVELOPMENT) {
|
||||||
create(server).info(`Server started`);
|
createReporter(server).info(`Server started`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
@@ -96,7 +96,7 @@ export function start(world: World, server: ServerConfig) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isErrorAlike(e)) {
|
if (isErrorAlike(e)) {
|
||||||
create(server).danger(e.message);
|
createReporter(server).danger(e.message);
|
||||||
}
|
}
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { IClient } from '../serverInterfaces';
|
|||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { isUserError, reportUserError2 } from '../userError';
|
import { isUserError, reportUserError2 } from '../userError';
|
||||||
import { includes } from '../../common/utils';
|
import { includes } from '../../common/utils';
|
||||||
import { create } from '../reporter';
|
import { createReporter } from '../reporter';
|
||||||
import { ServerConfig } from '../../common/adminInterfaces';
|
import { ServerConfig } from '../../common/adminInterfaces';
|
||||||
import { getOriginFromHTTP } from '../originUtils';
|
import { getOriginFromHTTP } from '../originUtils';
|
||||||
import { ServerActions } from '../serverActions';
|
import { ServerActions } from '../serverActions';
|
||||||
@@ -62,9 +62,9 @@ function reportError(rollbar: Rollbar | undefined, e: Error, client: IClient | u
|
|||||||
client.reporter.error(e);
|
client.reporter.error(e);
|
||||||
} else if (client && client.originalRequest) {
|
} else if (client && client.originalRequest) {
|
||||||
const origin = client.originalRequest && getOriginFromHTTP(client.originalRequest);
|
const origin = client.originalRequest && getOriginFromHTTP(client.originalRequest);
|
||||||
create(config, undefined, undefined, origin).error(e);
|
createReporter(config, undefined, undefined, origin).error(e);
|
||||||
} else {
|
} else {
|
||||||
create(config).error(e);
|
createReporter(config).error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rollbarIgnore.test(e.message)) {
|
if (!rollbarIgnore.test(e.message)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user