Commit Graph

28 Commits

Author SHA1 Message Date
Vladimir Bryzgalov 1f89052f72 fix(flamingo-helper): extract field values from _field_* meta, not _fields
Flamingo's '_fields' meta stores only the list of field NAMES with
null values; the actual values live in separate per-field meta keys
prefixed with '_field_'. The old extract_fields() returned the
null-valued '_fields' array on the first branch and never fell
through to the '_field_*' collector, so every retro Telegram message
showed '(не указан)' / '(пусто)' for every slot.

Also collect '_from_name' / '_from_email' (set by Akismet) as
convenience mappings to 'your-name' / 'your-email' so the formatter's
standard slots are populated for most submissions even when the form
uses custom field names like text-211 / name_user.

Pilot on washanyanya.ru caught this (retro delivered empty skeletons).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 23:46:52 +05:00
Vladimir Bryzgalov 22239321d0 fix(activator): register cron_schedules filter during activation
Dispatcher::register_hooks() runs on plugins_loaded, which is AFTER
register_activation_hook fires. The custom recurrence 'cf7stg_every_minute'
was therefore unknown to wp_schedule_event during activation, and the
'cf7stg_dispatch' event silently failed to schedule — queue items never
got dispatched.

Pilot caught this on washanyanya.ru (23 items queued, 0 sent, 0 failed —
no cron hook firing at all).

Adding the filter directly inside Activator::schedule_events() makes the
custom schedule available in the same request as the wp_schedule_event
call, regardless of bootstrap order.

After updating the plugin, deactivate + reactivate is required to
re-trigger Activator::activate() so events get (re)scheduled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 23:26:06 +05:00
Vladimir Bryzgalov 2e0a829e06 docs+tests: fix autoloader — underscores → hyphens + slug fallback
The regex '/([a-z0-9])([A-Z])/' does not split on underscores, so
Interface_Spam_Source, Settings_Page, Dashboard_Widget stayed as
'interface_spam_source', 'settings_page', 'dashboard_widget' after
strtolower — no file matched. Added str_replace('_', '-', ...).

Then Interface_Spam_Source's slug became 'interface-spam-source',
and the candidate 'includes/sources/interface-' . \$slug doubled
the prefix into 'interface-interface-spam-source.php'. Replaced
that candidate family with a slug-as-filename fallback that maps
interface-* slugs directly to their files.

Sanity check on plugin bootstrap: 17/17 classes/interfaces resolve.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 23:02:53 +05:00
Vladimir Bryzgalov 0c1be5b4cd feat: plugin bootstrap, autoloader, activation/deactivation hooks 2026-04-17 23:02:20 +05:00
Vladimir Bryzgalov a9d19a75a3 feat(admin): settings page with token/chat/site-title, test button, retro, queue state 2026-04-17 22:53:53 +05:00
Vladimir Bryzgalov 6eb2844429 chore: uninstall cleanup, WP readme 2026-04-17 22:51:33 +05:00
Vladimir Bryzgalov f5816e4648 feat(admin): dashboard widget shown only when there are failed queue items 2026-04-17 22:50:29 +05:00
Vladimir Bryzgalov fef22c1ff8 feat(activator): create queue table, schedule cron, guard PHP/WP versions 2026-04-17 22:49:25 +05:00
Vladimir Bryzgalov aa66d15eb5 feat(retro-importer): queue last-N Flamingo spam posts with dedup 2026-04-17 22:48:21 +05:00
Vladimir Bryzgalov eb199c6d40 feat(cf7-source): capture spam submissions via wpcf7_spam and submission status 2026-04-17 22:47:13 +05:00
Vladimir Bryzgalov 4ce2fac42d feat(dispatcher): WP-Cron tick with backoff and retention cleanup 2026-04-17 22:45:38 +05:00
Vladimir Bryzgalov 786a306f29 feat(telegram-client): sendMessage wrapper classifying permanent/transient errors 2026-04-17 22:44:41 +05:00
Vladimir Bryzgalov 1f85d009c4 feat(settings): options wrapper with wp-config constant override 2026-04-17 22:43:36 +05:00
Vladimir Bryzgalov f24cadc799 feat(flamingo-helper): locate flamingo_inbound posts and extract fields/reason 2026-04-17 22:42:38 +05:00
Vladimir Bryzgalov 09f2638066 feat(queue): CRUD, dedup, retention, status counters 2026-04-17 22:41:30 +05:00
Vladimir Bryzgalov cc37aa2647 feat(crypto): AES-256-CBC token encryption via AUTH_KEY 2026-04-17 22:40:08 +05:00
Vladimir Bryzgalov 6961bb1b72 feat(telegram): exception carrying permanent/retry_after flags 2026-04-17 22:39:04 +05:00
Vladimir Bryzgalov d3bd360357 feat(message-formatter): build Telegram HTML payload with inline tel button 2026-04-17 22:37:10 +05:00
Vladimir Bryzgalov a7b796d381 docs: honeypot is a hard override on label=spam
Previous plan/spec made honeypot a -5 weighted signal only. That is
insufficient to force 'spam' when the submission also has a RU phone
(+3), cyrillic name (+1), and meaningful text (+1) — a clean +5 cancels
-5, yielding 'unclear'. The honeypot test (test_honeypot_forces_spam_
even_with_phone) caught this.

Honeypot semantics: a filled hidden field is a bot by definition.
No combination of positive signals can make it a legitimate client.
Keeping the -5 weight on 'reasons' list for transparency, but adding
a hard override that sets label='spam' at the end of classify().

Caught by TDD on Task 7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 22:21:51 +05:00
Vladimir Bryzgalov 90940dd928 feat(classifier): weighted heuristic for client/unclear/spam scoring 2026-04-17 22:21:10 +05:00
Vladimir Bryzgalov 3dd0f41446 feat(phone-parser): normalize RU phones and extract first candidate 2026-04-17 22:08:57 +05:00
Vladimir Bryzgalov 558483ef44 docs: fix punycode example and regex delimiter in plan/spec
- xn--80aafmakjldfe1b5h.xn--p1ai decodes to "алквзелчкоеиа.рф", not
  "вашаняня.рф". Correct Punycode for "вашаняня.рф" is
  xn--80aae0ca7d8bb.xn--p1ai. Updated plan Task 2 test and spec §9.
- DomainFormatter strip-path regex '#[/?#].*$#' had the '#' delimiter
  colliding with the literal '#' inside the character class. Switched
  to tilde delimiters: '~[/?#].*$~'.

Both caught by TDD RED/GREEN loop on Task 3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 22:04:15 +05:00
Vladimir Bryzgalov 6068a6a54f feat(domain-formatter): decode punycode hosts to Cyrillic with fallbacks 2026-04-17 22:03:33 +05:00
Vladimir Bryzgalov 6aa1ef41e6 chore: add composer + phpunit dev scaffolding
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 21:53:22 +05:00
Vladimir Bryzgalov be00b7996c docs: add plan→bd ID map 2026-04-17 21:46:18 +05:00
Vladimir Bryzgalov 4569b5f586 docs: add implementation plan for cf7-spam-to-telegram
25 bite-sized TDD tasks covering composer/phpunit setup, pure-logic
classes (DomainFormatter, PhoneParser, Classifier, MessageFormatter)
with full test code, integration classes (Queue, Dispatcher, TelegramClient,
CF7Source, RetroImporter), admin UI, lifecycle hooks, and a manual
pilot on washanyanya.ru.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 21:36:35 +05:00
Vladimir Bryzgalov b1d8dfd044 bd init: initialize beads issue tracking 2026-04-17 21:28:59 +05:00
Vladimir Bryzgalov 3a998c36d2 docs: add design spec for cf7-spam-to-telegram plugin
Independent WP plugin that forwards CF7 spam submissions to a Telegram group,
applying a weighted heuristic (client/unclear/spam) to help operators
spot real inquiries mistakenly filtered as spam.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 21:26:51 +05:00