起名:添加屏蔽词检测
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pinus} from "pinus";
|
||||
// import { checkEvent } from '../../../services/eventSercive';
|
||||
import { refresh } from '../../../services/refreshService';
|
||||
import { checkPrivateChat, checkGuildChat, checkOtherChat, getWorldChannelSid } from "../../../services/chatService";
|
||||
import { resResult, checkWhiteListWithUid } from "../../../pubUtils/util";
|
||||
import { checkPrivateChat, checkGuildChat, checkOtherChat, getWorldChannelSid, checkRoleName, checkGuildName } from "../../../services/chatService";
|
||||
import { resResult, checkWhiteListWithUid, genCode } from "../../../pubUtils/util";
|
||||
import { CHANNEL_PREFIX, STATUS } from "../../../consts";
|
||||
import { UserModel } from "../../../db/User";
|
||||
import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam";
|
||||
@@ -19,6 +19,7 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
|
||||
const sid: string = session.get('sid');
|
||||
const roleId: string = session.get('roleId');
|
||||
const uid: number = session.get('userid');
|
||||
let guildCode = session.get('guildCode');
|
||||
|
||||
session.push('teamCode', () => {});
|
||||
|
||||
@@ -52,7 +53,6 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
|
||||
case 'chat.chatHandler.sendGroupMessage':
|
||||
{
|
||||
if(msg.channel == CHANNEL_PREFIX.GUILD) {
|
||||
const guildCode = session.get('guildCode');
|
||||
let result = await checkGuildChat(roleId, guildCode, msg.content);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
@@ -62,6 +62,24 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'role.roleHandler.rename':
|
||||
case 'role.roleHandler.initRole':
|
||||
{
|
||||
let result = await checkRoleName(roleId, msg.roleName);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
}
|
||||
case 'guild.guildHandler.createGuild':
|
||||
case 'guild.guildHandler.setGuildInfo':
|
||||
{
|
||||
if(!guildCode) {
|
||||
guildCode = genCode(6);
|
||||
msg.guildCode = guildCode;
|
||||
}
|
||||
let result = await checkGuildName(guildCode, serverId, msg.name, msg.notice);
|
||||
if(!result) hasBlockWords = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Application, BackendSession, ChannelService, HandlerService, pinus, } f
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { genCode, resResult } from "../../../pubUtils/util";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime } from "../../../services/auctionService";
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
@@ -254,7 +254,7 @@ export class AuctionHandler {
|
||||
const name = '测试公会'
|
||||
const icon = 1
|
||||
const notice = '测试公会'
|
||||
const guild = await GuildModel.createGuild({ name, icon, notice }, role, serverId);
|
||||
const guild = await GuildModel.createGuild({ guildCode: genCode(6), name, icon, notice }, role, serverId);
|
||||
if (!guild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
guild.leader = <RoleType>guild.leader;
|
||||
//创建科技树
|
||||
|
||||
@@ -40,13 +40,13 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// 创建军团
|
||||
async createGuild(msg: guildInter & { name: string, icon: number, notice: string }, session: BackendSession) {
|
||||
async createGuild(msg: guildInter & { guildCode: string } & { name: string, icon: number, notice: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const { name, icon, notice } = msg;
|
||||
const { name, icon, notice, guildCode } = msg;
|
||||
|
||||
// 检查名字是否重
|
||||
const checkNameResult = await GuildModel.checkName(name, serverId);
|
||||
@@ -66,7 +66,7 @@ export class GuildHandler {
|
||||
await handleCost(roleId, sid, [getGoldObject(ARMY.ARMY_CREAT_COST)]);
|
||||
|
||||
// 创建公会
|
||||
const guild = await GuildModel.createGuild({ name, icon, notice }, role, serverId);
|
||||
const guild = await GuildModel.createGuild({ guildCode, name, icon, notice }, role, serverId);
|
||||
if (!guild) return resResult(STATUS.GUILD_CREATE_ERROR);
|
||||
guild.leader = <RoleType>guild.leader;
|
||||
//创建科技树
|
||||
|
||||
@@ -15,9 +15,9 @@ import { channelServer } from './chatChannelService';
|
||||
import { AccuseRecModel, AccueseParam } from '../db/AccuseRec';
|
||||
import { getSimpleRoleInfo, getSimpleRoleInfos } from './roleService';
|
||||
import * as FCClient from '@alicloud/fc2';
|
||||
import { Chat37Params } from '../domain/sdk';
|
||||
import { Chat37Params, CheckGuild37Params, CheckName37Params } from '../domain/sdk';
|
||||
import { UserModel } from '../db/User';
|
||||
import { request37CheckChat } from '../pubUtils/httpUtil';
|
||||
import { request37CheckChat, request37Post } from '../pubUtils/httpUtil';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -442,6 +442,29 @@ export async function checkOtherChat(roleId: string, channelPrefix: string, mess
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function checkRoleName(roleId: string, roleName: string) {
|
||||
let myRole = await RoleModel.findByRoleId(roleId);
|
||||
let myUser = await UserModel.findUserByUid(myRole.userInfo.uid);
|
||||
let body = new CheckName37Params(myRole, roleName, myUser);
|
||||
if(myUser.channelType == '37') {
|
||||
return await request37Post(SDK_37_ADDR.CHECK_NAME, body, SDK_37_CONST.CHAT_KEY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function checkGuildName(guildCode: string, serverId: number, name: string, notice: string) {
|
||||
let nameResult = true, noticeResult = true;
|
||||
if(name) {
|
||||
let body = new CheckGuild37Params(guildCode, serverId, 1, name);
|
||||
nameResult = await request37Post(SDK_37_ADDR.CHECK_UNION, body, SDK_37_CONST.CHAT_KEY);
|
||||
}
|
||||
if(notice) {
|
||||
let body = new CheckGuild37Params(guildCode, serverId, 2, notice);
|
||||
noticeResult = await request37Post(SDK_37_ADDR.CHECK_UNION, body, SDK_37_CONST.CHAT_KEY);
|
||||
}
|
||||
return nameResult && noticeResult
|
||||
}
|
||||
|
||||
export async function pushCurrentTime(time: number) {
|
||||
let serverlists = await getAllServers()
|
||||
for(let serverId of serverlists) {
|
||||
|
||||
Reference in New Issue
Block a user