Skip to content

fix: make contains a substring match and compare authors by key - #28

Merged
DHEBP merged 1 commit into
devfrom
fix/content-filter-rules
Aug 29, 2026
Merged

fix: make contains a substring match and compare authors by key#28
DHEBP merged 1 commit into
devfrom
fix/content-filter-rules

Conversation

@DHEBP

@DHEBP DHEBP commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Two problems in evaluateRule, both filed as issue #27. Neither can fire today, because the shipped rulebook holds only rating and epoch_support rules and nothing exposed to the frontend creates a new one, so no author or category rule can exist yet. This closes a trap before someone wires up a rule editor.

The contains arms for author and category were each a copy of their eq arm, so the operator did exact equality. A rule saying contains games could never match games/arcade.

An author rule compared the app's stored author against a value the user typed in. A TELA app's stored author came from the DVM, which always renders the dero1 form because ADDRESS_STRING builds through rpc.NewAddressFromKeys and leaves Mainnet true. A wallet on a simulator shows deto1 for that same key. Addresses are bech32, so the prefix and the checksum both differ and the rule never matched its own author. sameINDEXAuthor, added in #26, already decodes both sides and compares keys, so eq uses it now.

contains stays a text match, because a substring of an address cannot be decoded. An author rule naming a whole address has to use eq.

Tests cover both renderings in both directions, a different author across networks, a rule value that is not an address, and substring vectors chosen so an equality compare rejects them. Reverting either fix fails its own test with the build still clean.

content_filter.go has pre-existing gofmt drift in its const block and struct tags. I left it alone so the diff stays readable.

Closes #27

…y key

Both problems are in evaluateRule and neither can fire today. The shipped
rulebook holds only rating and epoch_support rules, and nothing exposed to the
frontend creates a rule, so no author or category rule can exist yet. They would
have bitten whoever wired a rule editor.

The contains arms for author and category were each a copy of their eq arm, so
the operator did exact equality. A rule saying contains games could never match
games/arcade.

An author rule compared the app's stored author against a value the user typed.
For a TELA app the stored author came from the DVM, which always renders the
dero1 form because ADDRESS_STRING builds through rpc.NewAddressFromKeys and
leaves Mainnet true, since consensus cannot depend on which network a node
believes it is on. A user on a simulator copies deto1 out of their wallet.
Addresses are bech32, so the prefix and the checksum both differ and the rule
never matches its own author. sameINDEXAuthor already decodes both sides and
compares keys, so eq now uses it.

contains stays a text match, because a substring of an address cannot be
decoded. An author rule naming a whole address has to use eq.

Tests cover both renderings in both directions, a different author across
networks, a rule value that is not an address, and substring vectors chosen so
an equality compare rejects them. Mutation checked: reverting either fix fails
its own test with the build still clean.
@DHEBP
DHEBP merged commit 949e069 into dev Aug 29, 2026
2 checks passed
@DHEBP
DHEBP deleted the fix/content-filter-rules branch August 29, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

content_filter: contains operator does exact equality, and author rules would break across networks

1 participant