返回提交历史
Modified
src/controllers/api/getGuildLogController.ts
+14
-5
XFEstudio/XFESpaceNinjaServer
chore: remove numeric suffix from names in clan log for pre-U32 clients (#3540)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3540 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
6886865b
代码差异
1 个文件
+14
-5
@@ -1,4 +1,5 @@
1
import { toMongoDate2 } from "../../helpers/inventoryHelpers.ts";
1
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
2
import { toMongoDate2, version_compare } from "../../helpers/inventoryHelpers.ts";
2
3
import { Guild } from "../../models/guildModel.ts";
3
4
import { getInventory } from "../../services/inventoryService.ts";
4
5
import { getAccountForRequest } from "../../services/loginService.ts";
@@ -22,28 +23,28 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
22
23
log.RoomChanges.push({
23
24
dateTime: toMongoDate2(entry.dateTime ?? new Date(), account.BuildLabel),
24
25
entryType: entry.entryType,
25
details: entry.details
26
details: cleanupDetails(entry.details, account.BuildLabel)
26
27
});
27
28
});
28
29
guild.TechChanges?.forEach(entry => {
29
30
log.TechChanges.push({
30
31
dateTime: toMongoDate2(entry.dateTime ?? new Date(), account.BuildLabel),
31
32
entryType: entry.entryType,
32
details: entry.details
33
details: cleanupDetails(entry.details, account.BuildLabel)
33
34
});
34
35
});
35
36
guild.RosterActivity?.forEach(entry => {
36
37
log.RosterActivity.push({
37
38
dateTime: toMongoDate2(entry.dateTime, account.BuildLabel),
38
39
entryType: entry.entryType,
39
details: entry.details
40
details: cleanupDetails(entry.details, account.BuildLabel)
40
41
});
41
42
});
42
43
guild.ClassChanges?.forEach(entry => {
43
44
log.ClassChanges.push({
44
45
dateTime: toMongoDate2(entry.dateTime, account.BuildLabel),
45
46
entryType: entry.entryType,
46
details: entry.details
47
details: cleanupDetails(entry.details, account.BuildLabel)
47
48
});
48
49
});
49
50
res.json(log);
@@ -58,3 +59,11 @@ interface IGuildLogEntryClient {
58
59
entryType: number;
59
60
details: number | string;
60
61
}
62
63
const cleanupDetails = (details: number | string, buildLabel: string | undefined): number | string => {
64
if (typeof details == "string" && buildLabel && version_compare(buildLabel, gameToBuildVersion["32.0.0"]) < 0) {
65
// Remove the number suffix so pre-U32 clients don't show it. U32+ clients currently don't show it because we don't set CrossPlatformEnabled to true.
66
return details.split("#")[0];
67
}
68
return details;
69
};