Skip to content

Commit

Permalink
Merge pull request #793 from readthedocs/davidfischer/20-tags-max
Browse files Browse the repository at this point in the history
20 keywords maximum in API
  • Loading branch information
davidfischer authored Oct 9, 2023
2 parents 37e4c09 + 3e004cf commit b3df592
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions adserver/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ def validate_publisher(self, publisher_slug):
return publisher

def validate_keywords(self, keywords):
# API users may send more than this, but keywords beyond this are ignored
MAX_KEYWORDS = 20

if keywords:
# Lowercase all the keywords and strip surrounding whitespace
keywords = [k.lower().strip() for k in keywords if k.strip()]
# Lowercase all the keywords and strip surrounding whitespace.
# Also, only take the first 20.
keywords = [k.lower().strip() for k in keywords if k.strip()][:MAX_KEYWORDS]

return keywords

Expand Down

0 comments on commit b3df592

Please sign in to comment.