Skip to content
Snippets Groups Projects
Commit 84ce086f authored by Jason Salyers's avatar Jason Salyers
Browse files

[JES] Modifications to the follow op for the new blacklisting options. Now to...

[JES] Modifications to the follow op for the new blacklisting options. Now to figure out how to test it
parent 721a465d
No related branches found
No related tags found
No related merge requests found
...@@ -41,14 +41,32 @@ class Follow: ...@@ -41,14 +41,32 @@ class Follow:
old_state = cls._get_follow_db_state(op['flr'], op['flg']) old_state = cls._get_follow_db_state(op['flr'], op['flg'])
if new_state == (old_state or 0): if new_state == (old_state or 0):
return return
sql = ''
# insert or update state # insert or update state
if old_state is None: if old_state is None:
sql = """INSERT INTO hive_follows (follower, following, sql = """INSERT INTO hive_follows (follower, following,
created_at, state) VALUES (:flr, :flg, :at, :state)""" created_at, state, blacklisted, follow_blacklists) VALUES (:flr, :flg, :at, :state, %s, %s)"""
if new_state == 3:
sql = sql % """ true, false """
elif new_state == 4:
sql = sql % """ false, true """
else: else:
sql = """UPDATE hive_follows SET state = :state if new_state < 3:
WHERE follower = :flr AND following = :flg""" sql = """UPDATE hive_follows SET state = :state
WHERE follower = :flr AND following = :flg"""
elif new_state == 3:
sql = """UPDATE hive_follows SET blacklisted = true
WHERE follower = :flr AND following = :flg"""
elif new_state == 4:
sql = """UPDATE hive_follows SET follow_blacklists = true
WHERE follower = :flr AND following = :flg"""
elif new_state == 5:
sql = """UPDATE hive_follows SET blacklisted = false
WHERE follower = :flr AND following = :flg"""
elif new_state == 6:
sql = """UPDATE hive_follows SET follow_blacklists = false
WHERE follower = :flr AND following = :flg"""
DB.query(sql, **op) DB.query(sql, **op)
# track count deltas # track count deltas
...@@ -74,7 +92,7 @@ class Follow: ...@@ -74,7 +92,7 @@ class Follow:
what = first(op['what']) or '' what = first(op['what']) or ''
if not isinstance(what, str): if not isinstance(what, str):
return None return None
defs = {'': 0, 'blog': 1, 'ignore': 2} defs = {'': 0, 'blog': 1, 'ignore': 2, 'blacklist': 3, 'follow_blacklists': 4, 'unblacklist': 5, 'unfollow_blacklists': 6}
if what not in defs: if what not in defs:
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment