Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
crypto-news-service/Topic.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (18 sloc)
785 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Subscription import Subscription | |
from Mail import Mail | |
class Topic: | |
def __init__(self, topic) -> None: | |
self.topic = topic | |
self.subscriptions = {} | |
def subscribe(self, subscription: Subscription): | |
if subscription.user.email not in self.subscriptions.keys(): | |
self.subscriptions[subscription.user.email] = subscription | |
return | |
self.subscriptions[subscription.user.email].append(subscription) | |
def unsubscribe(self, user: User): | |
pass | |
def setFrequency(self, user: User, frequency): | |
self.subscribers[user.email] = frequency | |
def pushEmails(self, content, mail: Mail): | |
for email in self.subscribers.keys(): | |
mail.sendMail('News Service', email, content) |