@kaikybrofc/omnizap-system 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +534 -0
- package/LICENSE +21 -0
- package/README.md +431 -0
- package/RELEASE-v2.1.2.md +83 -0
- package/app/config/adminIdentity.js +87 -0
- package/app/config/baileysConfig.js +693 -0
- package/app/config/groupUtils.js +388 -0
- package/app/connection/socketController.js +992 -0
- package/app/controllers/messageController.js +354 -0
- package/app/modules/adminModule/groupCommandHandlers.js +1294 -0
- package/app/modules/adminModule/groupEventHandlers.js +355 -0
- package/app/modules/aiModule/catCommand.js +1006 -0
- package/app/modules/broadcastModule/noticeCommand.js +416 -0
- package/app/modules/gameModule/diceCommand.js +67 -0
- package/app/modules/menuModule/common.js +311 -0
- package/app/modules/menuModule/menus.js +59 -0
- package/app/modules/playModule/playCommand.js +1615 -0
- package/app/modules/quoteModule/quoteCommand.js +851 -0
- package/app/modules/rpgPokemonModule/rpgBattleCanvasRenderer.js +786 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.js +2082 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.test.js +760 -0
- package/app/modules/rpgPokemonModule/rpgEvolutionUtils.js +22 -0
- package/app/modules/rpgPokemonModule/rpgPokemonCommand.js +172 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.js +192 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.test.js +93 -0
- package/app/modules/rpgPokemonModule/rpgPokemonEvolution.test.js +46 -0
- package/app/modules/rpgPokemonModule/rpgPokemonMessages.js +746 -0
- package/app/modules/rpgPokemonModule/rpgPokemonRepository.js +1859 -0
- package/app/modules/rpgPokemonModule/rpgPokemonService.js +6738 -0
- package/app/modules/rpgPokemonModule/rpgProfileCanvasRenderer.js +354 -0
- package/app/modules/statsModule/globalRankingCommand.js +65 -0
- package/app/modules/statsModule/noMessageCommand.js +288 -0
- package/app/modules/statsModule/rankingCommand.js +60 -0
- package/app/modules/statsModule/rankingCommon.js +889 -0
- package/app/modules/stickerModule/addStickerMetadata.js +239 -0
- package/app/modules/stickerModule/convertToWebp.js +390 -0
- package/app/modules/stickerModule/stickerCommand.js +454 -0
- package/app/modules/stickerModule/stickerConvertCommand.js +156 -0
- package/app/modules/stickerModule/stickerTextCommand.js +657 -0
- package/app/modules/stickerPackModule/autoPackCollectorRuntime.js +20 -0
- package/app/modules/stickerPackModule/autoPackCollectorService.js +284 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.js +466 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.test.js +88 -0
- package/app/modules/stickerPackModule/semanticThemeClusterService.js +571 -0
- package/app/modules/stickerPackModule/stickerAssetClassificationRepository.js +449 -0
- package/app/modules/stickerPackModule/stickerAssetRepository.js +400 -0
- package/app/modules/stickerPackModule/stickerAssetReprocessQueueRepository.js +180 -0
- package/app/modules/stickerPackModule/stickerAutoPackByTagsRuntime.js +4078 -0
- package/app/modules/stickerPackModule/stickerClassificationBackgroundRuntime.js +598 -0
- package/app/modules/stickerPackModule/stickerClassificationService.js +588 -0
- package/app/modules/stickerPackModule/stickerMarketplaceDriftService.js +102 -0
- package/app/modules/stickerPackModule/stickerPackCatalogHttp.js +7506 -0
- package/app/modules/stickerPackModule/stickerPackCommandHandlers.js +1095 -0
- package/app/modules/stickerPackModule/stickerPackEngagementRepository.js +108 -0
- package/app/modules/stickerPackModule/stickerPackErrors.js +30 -0
- package/app/modules/stickerPackModule/stickerPackInteractionEventRepository.js +110 -0
- package/app/modules/stickerPackModule/stickerPackItemRepository.js +440 -0
- package/app/modules/stickerPackModule/stickerPackMarketplaceService.js +337 -0
- package/app/modules/stickerPackModule/stickerPackMessageService.js +296 -0
- package/app/modules/stickerPackModule/stickerPackRepository.js +442 -0
- package/app/modules/stickerPackModule/stickerPackService.js +788 -0
- package/app/modules/stickerPackModule/stickerPackServiceRuntime.js +51 -0
- package/app/modules/stickerPackModule/stickerPackUtils.js +97 -0
- package/app/modules/stickerPackModule/stickerStorageService.js +507 -0
- package/app/modules/stickerPackModule/stickerWorkerPipelineRuntime.js +233 -0
- package/app/modules/stickerPackModule/stickerWorkerTaskQueueRepository.js +205 -0
- package/app/modules/systemMetricsModule/pingCommand.js +421 -0
- package/app/modules/tiktokModule/tiktokCommand.js +798 -0
- package/app/modules/userModule/userCommand.js +1217 -0
- package/app/modules/waifuPicsModule/waifuPicsCommand.js +177 -0
- package/app/observability/metrics.js +734 -0
- package/app/services/captchaService.js +492 -0
- package/app/services/dbWriteQueue.js +572 -0
- package/app/services/groupMetadataService.js +279 -0
- package/app/services/lidMapService.js +663 -0
- package/app/services/messagePersistenceService.js +56 -0
- package/app/services/newsBroadcastService.js +351 -0
- package/app/services/pokeApiService.js +398 -0
- package/app/services/queueUtils.js +57 -0
- package/app/services/socketState.js +7 -0
- package/app/store/aiPromptStore.js +38 -0
- package/app/store/groupConfigStore.js +58 -0
- package/app/store/premiumUserStore.js +36 -0
- package/app/utils/antiLink/antiLinkModule.js +804 -0
- package/app/utils/http/getImageBufferModule.js +18 -0
- package/app/utils/json/jsonSanitizer.js +113 -0
- package/app/utils/json/jsonSanitizer.test.js +40 -0
- package/app/utils/logger/loggerModule.js +262 -0
- package/app/utils/systemMetrics/systemMetricsModule.js +91 -0
- package/database/index.js +2052 -0
- package/database/init.js +516 -0
- package/database/migrations/20260203_0001_sticker_packs.sql +54 -0
- package/database/migrations/20260210_0003_rpg_pokemon.sql +58 -0
- package/database/migrations/20260210_0004_rpg_shiny_biome.sql +9 -0
- package/database/migrations/20260210_0005_rpg_missions.sql +14 -0
- package/database/migrations/20260210_0006_rpg_world_pokedex_traits.sql +27 -0
- package/database/migrations/20260210_0007_rpg_raid_pvp.sql +56 -0
- package/database/migrations/20260210_0008_rpg_social_system.sql +195 -0
- package/database/migrations/20260211_0009_rpg_social_xp.sql +36 -0
- package/database/migrations/20260222_0010_remove_message_xp.sql +2 -0
- package/database/migrations/20260226_0011_sticker_asset_classification.sql +17 -0
- package/database/migrations/20260226_0012_sticker_pack_engagement.sql +16 -0
- package/database/migrations/20260226_0013_sticker_marketplace_intelligence.sql +19 -0
- package/database/migrations/20260226_0014_sticker_pack_publish_flow.sql +30 -0
- package/database/migrations/20260226_0014_sticker_worker_queues.sql +42 -0
- package/database/migrations/20260226_0015_sticker_auto_pack_curation_integrity.sql +18 -0
- package/database/migrations/20260226_0016_sticker_web_google_auth_persistence.sql +34 -0
- package/database/migrations/20260226_0017_sticker_web_admin_ban.sql +22 -0
- package/database/migrations/20260226_0018_sticker_web_admin_moderator.sql +18 -0
- package/database/migrations/20260227_0019_sticker_classification_v2_signals.sql +12 -0
- package/database/migrations/20260227_0020_semantic_theme_clusters.sql +35 -0
- package/docker-compose.yml +103 -0
- package/ecosystem.prod.config.cjs +35 -0
- package/eslint.config.js +61 -0
- package/index.js +437 -0
- package/ml/clip_classifier/Dockerfile +16 -0
- package/ml/clip_classifier/README.md +120 -0
- package/ml/clip_classifier/adaptive_scoring.py +40 -0
- package/ml/clip_classifier/classifier.py +654 -0
- package/ml/clip_classifier/embedding_store.py +481 -0
- package/ml/clip_classifier/env_loader.py +15 -0
- package/ml/clip_classifier/llm_label_expander.py +144 -0
- package/ml/clip_classifier/main.py +213 -0
- package/ml/clip_classifier/requirements.txt +10 -0
- package/ml/clip_classifier/similarity_engine.py +74 -0
- package/observability/alert-rules.yml +60 -0
- package/observability/grafana/dashboards/omnizap-mysql.json +136 -0
- package/observability/grafana/dashboards/omnizap-overview.json +170 -0
- package/observability/grafana/provisioning/dashboards/dashboards.yml +11 -0
- package/observability/grafana/provisioning/datasources/datasources.yml +15 -0
- package/observability/loki-config.yml +38 -0
- package/observability/mysql-exporter.cnf +5 -0
- package/observability/mysql-setup.sql +46 -0
- package/observability/prometheus.yml +32 -0
- package/observability/promtail-config.yml +84 -0
- package/package.json +109 -0
- package/public/api-docs/index.html +144 -0
- package/public/css/github-project-panel.css +297 -0
- package/public/css/stickers-admin.css +1272 -0
- package/public/css/styles.css +671 -0
- package/public/index.html +1311 -0
- package/public/js/apps/apiDocsApp.js +310 -0
- package/public/js/apps/createPackApp.js +2069 -0
- package/public/js/apps/homeApp.js +396 -0
- package/public/js/apps/stickersAdminApp.js +1744 -0
- package/public/js/apps/stickersApp.js +4830 -0
- package/public/js/catalog.js +1019 -0
- package/public/js/github-panel/components/CommitList.js +34 -0
- package/public/js/github-panel/components/ErrorState.js +16 -0
- package/public/js/github-panel/components/GithubProjectPanel.js +106 -0
- package/public/js/github-panel/components/ReleaseList.js +38 -0
- package/public/js/github-panel/components/SkeletonPanel.js +22 -0
- package/public/js/github-panel/components/StatCard.js +15 -0
- package/public/js/github-panel/index.js +15 -0
- package/public/js/github-panel/useGithubRepoData.js +154 -0
- package/public/js/github-panel/vendor/react.js +11 -0
- package/public/js/runtime/react-runtime.js +19 -0
- package/public/licenca/index.html +106 -0
- package/public/stickers/admin/index.html +23 -0
- package/public/stickers/create/index.html +47 -0
- package/public/stickers/index.html +48 -0
- package/public/termos-de-uso/index.html +125 -0
- package/scripts/cache-bust.mjs +107 -0
- package/scripts/deploy.sh +458 -0
- package/scripts/github-deploy-notify.mjs +174 -0
- package/scripts/release.sh +129 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { STICKER_PACK_ERROR_CODES, StickerPackError } from './stickerPackErrors.js';
|
|
2
|
+
import { sanitizeText } from './stickerPackUtils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Serviço responsável por direcionar figurinhas recém-criadas para packs automáticos.
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_AUTO_PACK_NAME = process.env.STICKER_PACK_AUTO_PACK_NAME || 'pack';
|
|
8
|
+
const AUTO_PACK_TARGET_VISIBILITY = 'unlisted';
|
|
9
|
+
const AUTO_COLLECT_ENABLED = process.env.STICKER_PACK_AUTO_COLLECT_ENABLED !== 'false';
|
|
10
|
+
const AUTO_PACK_NAME_MAX_LENGTH = 120;
|
|
11
|
+
const normalizeVisibility = (value) => String(value || '').trim().toLowerCase();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Escapa texto para uso seguro em RegExp.
|
|
15
|
+
*
|
|
16
|
+
* @param {unknown} value Valor de entrada.
|
|
17
|
+
* @returns {string} Valor escapado.
|
|
18
|
+
*/
|
|
19
|
+
const escapeRegex = (value) => String(value || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Remove acentos para facilitar normalização de nomes.
|
|
23
|
+
*
|
|
24
|
+
* @param {unknown} value Valor de entrada.
|
|
25
|
+
* @returns {string} Texto sem diacríticos.
|
|
26
|
+
*/
|
|
27
|
+
const removeDiacritics = (value) => String(value || '').normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Gera nome de pack automático válido no padrão aceito.
|
|
31
|
+
*
|
|
32
|
+
* @param {unknown} value Nome base.
|
|
33
|
+
* @param {{ fallback?: string, maxLength?: number }} [options] Configurações de fallback/tamanho.
|
|
34
|
+
* @returns {string} Nome normalizado.
|
|
35
|
+
*/
|
|
36
|
+
const normalizeAutoPackName = (value, { fallback = 'pack', maxLength = AUTO_PACK_NAME_MAX_LENGTH } = {}) => {
|
|
37
|
+
const sanitized = sanitizeText(value, maxLength, { allowEmpty: true }) || '';
|
|
38
|
+
const normalized = removeDiacritics(sanitized)
|
|
39
|
+
.toLowerCase()
|
|
40
|
+
.replace(/[^a-z0-9]+/g, '')
|
|
41
|
+
.slice(0, maxLength);
|
|
42
|
+
|
|
43
|
+
return normalized || fallback;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Monta candidato incremental para nome de pack automático.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} base Base do nome.
|
|
50
|
+
* @param {number} index Índice incremental.
|
|
51
|
+
* @returns {string} Nome candidato.
|
|
52
|
+
*/
|
|
53
|
+
const buildAutoPackCandidate = (base, index) => {
|
|
54
|
+
const suffix = String(index);
|
|
55
|
+
const maxBaseLength = Math.max(1, AUTO_PACK_NAME_MAX_LENGTH - suffix.length);
|
|
56
|
+
const trimmedBase = normalizeAutoPackName(base, { fallback: 'pack', maxLength: maxBaseLength });
|
|
57
|
+
return `${trimmedBase}${suffix}`;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Define o próximo nome disponível para auto packs.
|
|
62
|
+
*
|
|
63
|
+
* @param {Array<{name?: string}>} packs Packs já existentes.
|
|
64
|
+
* @returns {string} Nome único sugerido.
|
|
65
|
+
*/
|
|
66
|
+
const makeAutoPackName = (packs) => {
|
|
67
|
+
const base = normalizeAutoPackName(DEFAULT_AUTO_PACK_NAME, { fallback: 'pack', maxLength: AUTO_PACK_NAME_MAX_LENGTH });
|
|
68
|
+
const normalizedBase = base.toLowerCase();
|
|
69
|
+
const existingNames = packs
|
|
70
|
+
.map((pack) => normalizeAutoPackName(pack?.name, { fallback: '', maxLength: AUTO_PACK_NAME_MAX_LENGTH }))
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.map((name) => name.toLowerCase());
|
|
73
|
+
const existingSet = new Set(existingNames);
|
|
74
|
+
const usedIndexes = new Set();
|
|
75
|
+
const matcher = new RegExp(`^${escapeRegex(normalizedBase)}(\\d+)?$`, 'i');
|
|
76
|
+
|
|
77
|
+
for (const name of existingNames) {
|
|
78
|
+
const match = name.match(matcher);
|
|
79
|
+
if (!match) continue;
|
|
80
|
+
|
|
81
|
+
if (!match[1]) {
|
|
82
|
+
usedIndexes.add(1);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const parsedIndex = Number(match[1]);
|
|
87
|
+
if (Number.isInteger(parsedIndex) && parsedIndex > 0) {
|
|
88
|
+
usedIndexes.add(parsedIndex);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let index = 1;
|
|
93
|
+
while (index < 10_000) {
|
|
94
|
+
const candidate = buildAutoPackCandidate(base, index);
|
|
95
|
+
if (!usedIndexes.has(index) && !existingSet.has(candidate.toLowerCase())) {
|
|
96
|
+
return candidate;
|
|
97
|
+
}
|
|
98
|
+
index += 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const fallbackIndex = Math.max(1, packs.length + 1);
|
|
102
|
+
return buildAutoPackCandidate(base, fallbackIndex);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Cria coletor automático de figurinhas para packs.
|
|
107
|
+
*
|
|
108
|
+
* @param {{
|
|
109
|
+
* enabled?: boolean,
|
|
110
|
+
* logger?: { info?: Function, warn?: Function, error?: Function, debug?: Function },
|
|
111
|
+
* stickerPackService?: object,
|
|
112
|
+
* saveStickerAssetFromBuffer?: Function,
|
|
113
|
+
* }} [options] Dependências/configurações de runtime.
|
|
114
|
+
* @returns {{ addStickerToAutoPack: Function }} API do coletor.
|
|
115
|
+
*/
|
|
116
|
+
export function createAutoPackCollector(options = {}) {
|
|
117
|
+
const deps = {
|
|
118
|
+
logger: {
|
|
119
|
+
info: () => {},
|
|
120
|
+
warn: () => {},
|
|
121
|
+
error: () => {},
|
|
122
|
+
debug: () => {},
|
|
123
|
+
},
|
|
124
|
+
stickerPackService: null,
|
|
125
|
+
saveStickerAssetFromBuffer: null,
|
|
126
|
+
...options,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const isEnabled = options.enabled ?? AUTO_COLLECT_ENABLED;
|
|
130
|
+
|
|
131
|
+
if (isEnabled) {
|
|
132
|
+
if (!deps.stickerPackService || typeof deps.stickerPackService.listPacks !== 'function') {
|
|
133
|
+
throw new Error('createAutoPackCollector: stickerPackService inválido.');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (typeof deps.saveStickerAssetFromBuffer !== 'function') {
|
|
137
|
+
throw new Error('createAutoPackCollector: saveStickerAssetFromBuffer é obrigatório.');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const ensureAutoPackVisibility = async ({ ownerJid, pack }) => {
|
|
142
|
+
if (!pack) return pack;
|
|
143
|
+
|
|
144
|
+
if (normalizeVisibility(pack.visibility) === AUTO_PACK_TARGET_VISIBILITY) {
|
|
145
|
+
return pack;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (typeof deps.stickerPackService.setPackVisibility !== 'function') {
|
|
149
|
+
return { ...pack, visibility: AUTO_PACK_TARGET_VISIBILITY };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const updated = await deps.stickerPackService.setPackVisibility({
|
|
154
|
+
ownerJid,
|
|
155
|
+
identifier: pack.id || pack.pack_key,
|
|
156
|
+
visibility: AUTO_PACK_TARGET_VISIBILITY,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
deps.logger.info('Visibilidade do pack automático ajustada para unlisted.', {
|
|
160
|
+
action: 'sticker_pack_auto_collect_visibility_adjusted',
|
|
161
|
+
owner_jid: ownerJid,
|
|
162
|
+
pack_id: updated?.id || pack.id || null,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return updated || { ...pack, visibility: AUTO_PACK_TARGET_VISIBILITY };
|
|
166
|
+
} catch (error) {
|
|
167
|
+
deps.logger.warn('Falha ao ajustar visibilidade do pack automático.', {
|
|
168
|
+
action: 'sticker_pack_auto_collect_visibility_adjust_failed',
|
|
169
|
+
owner_jid: ownerJid,
|
|
170
|
+
pack_id: pack.id || null,
|
|
171
|
+
error: error?.message,
|
|
172
|
+
});
|
|
173
|
+
return pack;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const ensureTargetPack = async ({ ownerJid, senderName }) => {
|
|
178
|
+
const packs = await deps.stickerPackService.listPacks({ ownerJid, limit: 30 });
|
|
179
|
+
if (packs.length > 0) {
|
|
180
|
+
const preferredPack =
|
|
181
|
+
packs.find((entry) => normalizeVisibility(entry?.visibility) === AUTO_PACK_TARGET_VISIBILITY) || packs[0];
|
|
182
|
+
const ensuredPack = await ensureAutoPackVisibility({ ownerJid, pack: preferredPack });
|
|
183
|
+
return {
|
|
184
|
+
pack: ensuredPack,
|
|
185
|
+
packs,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const created = await deps.stickerPackService.createPack({
|
|
190
|
+
ownerJid,
|
|
191
|
+
name: makeAutoPackName([]),
|
|
192
|
+
publisher: sanitizeText(senderName, 120, { allowEmpty: true }) || 'OmniZap',
|
|
193
|
+
description: 'Coleção automática de figurinhas criadas pelo usuário.',
|
|
194
|
+
visibility: AUTO_PACK_TARGET_VISIBILITY,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
pack: created,
|
|
199
|
+
packs: [created],
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const addStickerToAutoPack = async ({ ownerJid, senderName, stickerBuffer }) => {
|
|
204
|
+
if (!isEnabled) {
|
|
205
|
+
return { status: 'skipped', reason: 'disabled' };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!Buffer.isBuffer(stickerBuffer) || !stickerBuffer.length) {
|
|
209
|
+
return { status: 'skipped', reason: 'invalid_buffer' };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const asset = await deps.saveStickerAssetFromBuffer({
|
|
213
|
+
ownerJid,
|
|
214
|
+
buffer: stickerBuffer,
|
|
215
|
+
mimetype: 'image/webp',
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const { pack: targetPack, packs } = await ensureTargetPack({ ownerJid, senderName });
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
const updated = await deps.stickerPackService.addStickerToPack({
|
|
222
|
+
ownerJid,
|
|
223
|
+
identifier: targetPack.id,
|
|
224
|
+
asset,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
deps.logger.info('Figurinha adicionada automaticamente ao pack.', {
|
|
228
|
+
action: 'sticker_pack_auto_collect',
|
|
229
|
+
owner_jid: ownerJid,
|
|
230
|
+
pack_id: updated.id,
|
|
231
|
+
sticker_id: asset.id,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
status: 'added',
|
|
236
|
+
pack: updated,
|
|
237
|
+
asset,
|
|
238
|
+
};
|
|
239
|
+
} catch (error) {
|
|
240
|
+
if (error instanceof StickerPackError && error.code === STICKER_PACK_ERROR_CODES.DUPLICATE_STICKER) {
|
|
241
|
+
return {
|
|
242
|
+
status: 'duplicate',
|
|
243
|
+
pack: targetPack,
|
|
244
|
+
asset,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (error instanceof StickerPackError && error.code === STICKER_PACK_ERROR_CODES.PACK_LIMIT_REACHED) {
|
|
249
|
+
const created = await deps.stickerPackService.createPack({
|
|
250
|
+
ownerJid,
|
|
251
|
+
name: makeAutoPackName(packs),
|
|
252
|
+
publisher: sanitizeText(senderName, 120, { allowEmpty: true }) || targetPack.publisher || 'OmniZap',
|
|
253
|
+
description: 'Coleção automática de figurinhas criadas pelo usuário.',
|
|
254
|
+
visibility: AUTO_PACK_TARGET_VISIBILITY,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const updated = await deps.stickerPackService.addStickerToPack({
|
|
258
|
+
ownerJid,
|
|
259
|
+
identifier: created.id,
|
|
260
|
+
asset,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
deps.logger.info('Figurinha adicionada ao novo pack automático após limite.', {
|
|
264
|
+
action: 'sticker_pack_auto_collect_rollover',
|
|
265
|
+
owner_jid: ownerJid,
|
|
266
|
+
pack_id: updated.id,
|
|
267
|
+
sticker_id: asset.id,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
status: 'added',
|
|
272
|
+
pack: updated,
|
|
273
|
+
asset,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
addStickerToAutoPack,
|
|
283
|
+
};
|
|
284
|
+
}
|