Skip to content

Commit

Permalink
Merge pull request #84 from leozqin/fix-unretrievable
Browse files Browse the repository at this point in the history
Fix unretrievable
  • Loading branch information
leozqin authored Dec 7, 2024
2 parents 6423ed7 + 9677faa commit 1ff7112
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def get_content(
url=entry.url,
content=content,
summary=markdown(summary) if summary else None,
unretrievable=True if content else False,
unretrievable=False if content else True,
)

except Exception as e:
Expand Down
10 changes: 9 additions & 1 deletion app/notification/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ class SlackNotificationHandler(NotificationHandler):
channel_name: str
routing: Mapping[str, str] = {}

@staticmethod
def _escape_title(title: str) -> str:
translation_table = {"&": "&amp;", "<": "&lt;", ">": "&gt;"}

# Iterate over the string and replace characters if needed
return "".join(translation_table.get(c, c) for c in title)

async def send_notification(self, feed: Feed, entry: FeedEntry):
client = AsyncWebClient(token=self.token)
title = self._escape_title(entry.title)

msg = f"{feed.name}: <{self.make_read_link(entry)}|{entry.title}>"
msg = f"{feed.name}: <{self.make_read_link(entry)}|{title}>"

if feed.notify_destination:
channel = self.routing.get(feed.notify_destination, self.channel_name)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "precis"
version = "0.3.5"
version = "0.3.6"
description = "A framework for automating your media diet"
requires-python = ">=3.11"
license = {file = "LICENSE"}
Expand Down

0 comments on commit 1ff7112

Please sign in to comment.