Commit Graph

35 Commits

Author SHA1 Message Date
SlimusMinus
2f52e6df70 Rework ad serving: signed impression tokens, per-campaign daily caps, stats
Follows the usual ad-server flow (serve -> impression -> click):
- GET /api/ads/next returns an impressionToken: HMAC-signed (ads.tracking.secret,
  defaults to jwt.secret) ad id, campaign id, subject and nonce, valid 1 hour.
  /impression and /click accept it, verify the signature, count each nonce once
  (Redis SET NX) and take the user/session from the token, so impressions
  cannot be forged or replayed. Requests without a token keep working until
  ads.tracking.require-token is switched on after the frontend update.
- The frequency cap is per campaign and calendar day (ads.timezone) and grows
  on real impressions, not on serving: ad:cap:<subject>:<campaign>:<yyyyMMdd>.
- Selection reads a 30-second in-memory snapshot of eligible ads (projection,
  invalidated locally on admin changes), filters capped campaigns with one
  MGET, picks by weight and then sets the cooldown atomically. The weighted
  sort drew random numbers inside the comparator, breaking its contract.
- Campaigns past endDate are finished every 10 minutes (ShedLock).
- GET /api/v1/admin/campaigns/{id}/stats: impressions, clicks and CTR per ad
  for a date range; composite indexes on impression/click (changelog 021).
- Removed unused cascade collections on Campaign/Advertising, the unused
  FullscreenAdActivateRequestDto and the /api/ads/impression/beacon rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:37:32 +03:00
SlimusMinus
477737c161 Hide private profile data and reissue tokens when users change their login
- GET /api/v1/users/{id} returns email and phone only to the user themself
  and to admins.
- When a user changes their own login, the PUT response carries a new token
  pair (login is the JWT subject, so the old tokens stop matching); old
  refresh tokens fail on their own because the stored login differs.
- The old avatar is deleted only after the profile is saved; login length is
  checked against the column size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:32:13 +03:00
SlimusMinus
a909b1f08b Fix advertising admin flows, tracking endpoints and ffmpeg timeout
- createAdvertising saved an IMAGE ad without mediaKey and only then answered
  400; validation now happens first. Target URLs must be absolute http(s)
  (they end up in href on the client), DTOs get @NotNull/@NotBlank.
- confirm-upload accepted any sourceKey; the transcoder deletes the source
  afterwards, so another ad's finished video could be deleted. Keys must now
  belong to the ad's own sources/ prefix.
- Activating a fullscreen ad could hit uq_fullscreen_ad_single_active because
  Hibernate may flush the new ACTIVE row first; the old one is flushed first.
- Campaign status change answered with the previous status (bulk UPDATE vs
  stale entity).
- Impression/click used getReferenceById, so unknown ids failed with 500 on
  the FK at commit; session ids are trimmed to the 64-char column.
- /api/ads/next created a Tomcat HttpSession for every client without
  X-Session-Id and failed with 500 when Redis was down; it now falls back to
  the client IP and returns 204 on Redis errors.
- ffmpeg output was read before waitFor, so the 5-minute timeout never fired;
  output goes to a temp log and its tail is logged on failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:04:10 +03:00
SlimusMinus
6e001fbc41 Fix post deletion, moderation races and cache leftovers
- PostService.delete did not remove favorites (FK without cascade -> 500 once a
  post was favorited) or chat links; owner, admin and nightly cleanup now share
  PostDeletionService, which deletes MinIO files only after commit. The nightly
  job also removes the images of expired posts.
- Moderation reads a snapshot in a short transaction, calls AI outside of it and
  applies the verdict only if the post is still in MODERATION and unchanged, so
  an edit made during a check can no longer go live unmoderated. Storage/AI
  outages keep the post in MODERATION instead of rejecting it.
- Posts without a category broke PostMapper with an NPE; title/phone/reward and
  address are checked against column sizes; a long address no longer overflows
  posts.city; Nominatim outages fall back to the address instead of 503.
- Favorites list hides posts that are back in moderation or rejected.
- Statistics counters use atomic UPDATEs instead of read-modify-write.
- Removed MapCacheService: its version key was bumped but never read.
- hibernate.default_batch_fetch_size=50 removes N+1 on images/users; show-sql
  is off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:02:12 +03:00
SlimusMinus
01ac227bdb fixed address for map 2026-10-15 00:02:10 +03:00
SlimusMinus
cd0d2a4081 create chats only together with the first message
- GET /api/v1/chats/with/{otherUserId}?postId= finds an existing chat
  (404 if there is none) and never creates one
- POST /api/v1/chats/with/{otherUserId}/messages?postId= with {content}
  finds or creates the chat and saves the first message in one
  transaction; same participant/post checks as before, WebSocket events
  still sent after commit
- the old POST /with/{otherUserId} that created empty chats is removed
- chat list hides chats without messages (existing empty rows stay in DB)
- empty messages are rejected with 400

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 01:45:18 +03:00
SlimusMinus
e53c5e3ba7 added latitude and longitude in PostResponse 2026-10-06 01:21:56 +03:00
SlimusMinus
bffd259c25 added all edit posts for admin 2026-10-02 01:54:19 +03:00
SlimusMinus
870739f45f added posts on feed and posts on map 2026-09-29 01:03:54 +03:00
SlimusMinus
0afb2397cf deleted likes 2026-09-24 00:18:13 +03:00
SlimusMinus
942cd09585 added advertising 2026-09-23 23:34:05 +03:00
SlimusMinus
5b06b420ef added reward text 2026-09-10 01:02:03 +03:00
SlimusMinus
a44b6c42ba added searchMap methods 2026-08-20 01:35:23 +03:00
SlimusMinus
8363d1602c fixed response chats 2026-08-13 00:34:24 +03:00
SlimusMinus
13ed934c60 fixed web-socket and add rewards on post 2026-08-12 00:41:31 +03:00
SlimusMinus
7429515143 fixed GeocodingService add alter city 2026-08-04 00:33:17 +03:00
SlimusMinus
7660128d96 added refresh token 2026-08-03 02:43:46 +03:00
SlimusMinus
2468c26b84 fixed controllers 2026-07-31 01:08:53 +03:00
SlimusMinus
844b369f07 added field rules_accepted in posts 2026-07-29 01:22:49 +03:00
SlimusMinus
a6fb187212 added ai-moderation image and text 2026-07-29 00:56:32 +03:00
SlimusMinus
1aee780ba1 added role for posts 2026-06-30 00:29:13 +03:00
SlimusMinus
ec5cc6cedd added scheduler for delete old or found posts 2026-06-25 00:48:55 +03:00
SlimusMinus
196b82dcc0 added likes on post 2026-06-25 00:07:02 +03:00
SlimusMinus
c49f2d108b added reviews 2026-06-23 00:09:57 +03:00
SlimusMinus
236d00f2f9 added chats with another users 2026-06-22 01:08:47 +03:00
SlimusMinus
5312f84eb8 added lastName on users 2026-06-19 00:29:05 +03:00
SlimusMinus
bafb636cbe added security and fix edit profile 2026-06-18 00:22:50 +03:00
SlimusMinus
e4b07fcbff fixed category in posts 2026-06-11 00:52:56 +03:00
SlimusMinus
c68cdf1c3e added card on post and feed 2026-06-04 00:32:51 +03:00
SlimusMinus
723e92baf1 added image for post 2026-06-01 01:57:16 +03:00
SlimusMinus
62d55d70d0 added phone for post 2026-05-29 01:19:10 +03:00
SlimusMinus
90016d2cd6 added get and create post 2026-05-07 01:08:29 +03:00
SlimusMinus
dfcd77fe88 del front and add auth 2026-05-04 00:46:20 +03:00
SlimusMinus
263242e469 start backend 2026-03-26 00:21:30 +03:00
SlimusMinus
611b1c82ad added start backend 2026-03-24 00:34:04 +03:00