Files
sorsfonalak/crates/db/migrations/0021_share_reward.sql
T
fecoandClaude Opus 5.5 19df36369c
CI / test (push) Successful in 1m9s
CI / build (push) Successful in 5m9s
CI / deploy (push) Skipped
Share reward and less robot load on shared links
The first visit of a shared link by someone else earns the sharer one free
natal analysis, once per user. The share page reports visits from the
visitor's browser; robots, the logged-in sharer and the address the link was
made at do not count. The share button is a proper card that says so in small
print; /v1/me tells whether the reward is used up.

Robots: reading a share writes nothing (view_count counts people only), the
frontend keeps shared content for five minutes (cleared when a link is
revoked), and robots.txt turns away the known AI crawlers while leaving the
link preview robots alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-19 09:26:06 +00:00

15 lines
900 B
SQL

-- A free natal analysis, once per user, when someone else first opens a link
-- they shared (counted from the share page in the visitor's browser, so link
-- preview robots do not count).
ALTER TABLE credit_ledger DROP CONSTRAINT credit_ledger_reason_check;
ALTER TABLE credit_ledger ADD CONSTRAINT credit_ledger_reason_check
CHECK (reason IN ('monthly_grant', 'analysis', 'chat', 'refund', 'admin_adjust', 'purchase', 'person', 'package',
'question', 'share_reward'));
CREATE UNIQUE INDEX credit_ledger_share_reward_once ON credit_ledger (user_id) WHERE reason = 'share_reward';
-- Hash of the sharer's address when the link was made (salted with the slug):
-- a visit from there is the sharer, not someone else.
ALTER TABLE shares ADD COLUMN owner_ip_hash bytea;
COMMENT ON COLUMN shares.view_count IS 'visits by people (the share page reports them), robots excluded';