-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from steemit/mutes
account mutes
- Loading branch information
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""List of muted accounts for server process.""" | ||
|
||
import logging | ||
from urllib.request import urlopen | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class Mutes: | ||
"""Singleton tracking muted accounts.""" | ||
|
||
_instance = None | ||
accounts = set() | ||
|
||
@classmethod | ||
def instance(cls): | ||
"""Get the shared instance.""" | ||
assert cls._instance, 'set_shared_instance was never called' | ||
return cls._instance | ||
|
||
@classmethod | ||
def set_shared_instance(cls, instance): | ||
"""Set the global/shared instance.""" | ||
cls._instance = instance | ||
|
||
def __init__(self, url): | ||
"""Initialize a muted account list by loading from URL""" | ||
if url: | ||
self.accounts = set(urlopen(url).read().decode('utf8').split()) | ||
|
||
@classmethod | ||
def all(cls): | ||
"""Return the set of all muted accounts from singleton instance.""" | ||
return cls.instance().accounts |
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
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
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