Skip to content

Commit

Permalink
Respond with error when trying to subscribe to already subscribed feed
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 10, 2021
1 parent 79cd475 commit db49264
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rss/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,15 @@ async def subscribe(self, evt: MessageEvent, url: str) -> None:
self.db.add_entries(entries, override_feed_id=feed.id)
elif feed.error_count > 0:
self.db.set_backoff(feed, error_count=feed.error_count, next_retry=0)
self.db.subscribe(feed.id, evt.room_id, evt.sender)
await evt.reply(f"Subscribed to feed ID {feed.id}: [{feed.title}]({feed.url})")
feed_info = f"feed ID {feed.id}: [{feed.title}]({feed.url})"
sub, _ = self.db.get_subscription(feed.id, evt.room_id)
if sub is not None:
subscriber = ("You" if sub.user_id == evt.sender
else f"[{sub.user_id}](https://matrix.to/#/{sub.user_id})")
await evt.reply(f"{subscriber} had already subscribed this room to {feed_info}")
else:
self.db.subscribe(feed.id, evt.room_id, evt.sender)
await evt.reply(f"Subscribed to {feed_info}")

@rss.subcommand("unsubscribe", aliases=("u", "unsub"),
help="Unsubscribe this room from a feed.")
Expand Down

0 comments on commit db49264

Please sign in to comment.