sdk: 根据37要求修改问题

This commit is contained in:
luying
2021-12-03 17:28:16 +08:00
parent a6ee89854a
commit 000742ace7
5 changed files with 26 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pin
import { refresh } from '../../../services/refreshService';
import { checkPrivateChat, checkGuildChat, checkOtherChat, checkRoleName, checkGuildName } from "../../../services/sdkService";
import { resResult, checkWhiteListWithUid, genCode } from "../../../pubUtils/util";
import { CHANNEL_PREFIX, STATUS } from "../../../consts";
import { CHANNEL_PREFIX, MSG_TYPE, STATUS } from "../../../consts";
import { UserModel } from "../../../db/User";
import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam";
export function globalFilter(app: Application) {
@@ -46,12 +46,14 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
switch(routeRecord.route) {
case 'chat.chatHandler.sendPrivateMessage':
{
if(msg.type == MSG_TYPE.IMG) break;
let result = await checkPrivateChat(roleId, msg.targetRoleId, msg.content);
if(!result) hasBlockWords = true;
break;
}
case 'chat.chatHandler.sendGroupMessage':
{
if(msg.type == MSG_TYPE.IMG) break;
if(msg.channel == CHANNEL_PREFIX.GUILD) {
let result = await checkGuildChat(roleId, guildCode, msg.content);
if(!result) hasBlockWords = true;

View File

@@ -26,7 +26,7 @@ import { getActivities } from '../../../services/activity/activityService';
import * as dicParam from '../../../pubUtils/dicParam';
import Counter from '../../../db/Counter';
import { UserModel } from '../../../db/User';
import { checkFilterWords, reportTAEvent } from '../../../services/sdkService';
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -614,4 +614,16 @@ export class RoleHandler {
return resResult(STATUS.SUCCESS);
}
async debugTreatRoleName(msg: { magicWord: string }, session: BackendSession) {
let roleId: string = session.get('roleId');
let { magicWord } = msg;
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
await treatRoleName(roleId, true);
return resResult(STATUS.SUCCESS);
}
}

View File

@@ -12,7 +12,7 @@ import { GuildModel } from "../db/Guild";
import { getRoleOnlineInfo, updateUserInfo } from "./redisService";
import { Application, pinus } from "pinus";
import { getGuildChannelSid } from "./chatService";
import { getRandSingleEelm, readWordTxt, writeWordTxt } from "../pubUtils/util";
import { getRandSingleEelm, readWordTxt, resResult, writeWordTxt } from "../pubUtils/util";
const ThinkingAnalytics = require("thinkingdata-node");
import Trie from '../pubUtils/trie';
import _ = require("underscore");
@@ -99,9 +99,9 @@ export async function checkGuildName(guildCode: string, serverId: number, name:
// 根据37sdk处理违规玩家名
export async function treatRoleName(roleId: string) {
export async function treatRoleName(roleId: string, isDebug?: boolean) {
let role = await RoleModel.findByRoleId(roleId);
if(role && role.sdkMark) { // 有设置标记的情况下
if((role && role.sdkMark) || isDebug) { // 有设置标记的情况下
let newName = "默认玩家名";
// 新名字上传
await checkRoleName(roleId, newName, role);
@@ -112,6 +112,9 @@ export async function treatRoleName(roleId: string) {
const { sid } = await getRoleOnlineInfo(roleId);
if(!!sid) {
await pinus.app.rpc.connector.connectorRemote.setOtherUserRoleNameSession.toServer(sid,[{ roleId, roleName: newName }]); // 改session
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
roleName: newName
}), [{uid: roleId, sid}]);
}
// 补偿
let gold = getGoldObject(NAMEPLATE.NAMEPLATE_FEECOST)

View File

@@ -83,7 +83,9 @@ module.exports = {
'optional uInt32 giftGold': 2,
'optional uInt32 gold': 3,
'optional uInt32 ap': 4,
'optional uInt32 totalPay': 5
'optional uInt32 totalPay': 5,
'optional uInt32 totalCost': 6,
'optional string roleName': 7,
},
'required string msg': 1,
'required uInt32 code': 2,

View File

@@ -309,7 +309,7 @@ export default class Auth extends Service {
const code = ctx.service.utils.genCode(6);
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName: roleId, seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName: "", seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
if (role) {
// 任务
await checkTask(roleId, TASK_TYPE.ROLE_LV, role.lv, false, {});