Skip to content

Commit

Permalink
Include employer name and browse URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Dec 2, 2024
1 parent ee2f142 commit 210d048
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions hasjob/socialmedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def bluesky_post(
url: str,
location: str | None = None,
parsed_location=None,
employer: str | None = None,
employer_url: str | None = None,
):
locationtags = []
if parsed_location:
Expand All @@ -117,12 +119,20 @@ def bluesky_post(
locationtags.append(locationtag)

maxlength = 300 # Bluesky allows 300 characters
if employer:
maxlength -= len(employer) + 2 # Minus employer name and prefix
if locationtags:
# Subtract length of all tags, plus length of visible `#`s and one space
maxlength -= len(' '.join(locationtags)) + len(locationtags) + 1

content = atproto_client_utils.TextBuilder()
content.link(title[: maxlength - 1] + '…' if len(title) > maxlength else title, url)
if employer:
content.text(' –')
if employer_url:
content.link(employer, employer_url)
else:
content.text(employer)
if locationtags:
for loc in locationtags:
content.text(' ')
Expand Down
4 changes: 3 additions & 1 deletion hasjob/views/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,12 @@ def confirm_email(domain, hashid, key):
)
if app.config['BLUESKY_ENABLED']:
bluesky_post.queue(
f'{post.headline}{post.company_name}',
post.headline,
post.url_for(_external=True),
post.location,
dict(post.parsed_location or {}),
employer=post.company_name,
employer_url=post.url_for('browse', _external=True),
)
add_to_boards.queue(post.id)
flash(
Expand Down

0 comments on commit 210d048

Please sign in to comment.