portal: derive source from OC email visibility instead of trusting a stale flag
ci/woodpecker/push/woodpecker Pipeline was canceled
ci/woodpecker/push/woodpecker Pipeline was canceled
oc-incognito disables email matching by design, so a profile that later shows an email leaves the member silently unmatched. The sweep now flips those to oc and records oc_email; profiles still hiding an email are untouched. Test covers both.
This commit is contained in:
1 parent
35735d67a5
commit
ffe62d3c78
2 files changed
+69
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import asyncio, os, sys, tempfile
|
||||
os.environ["DB_PATH"] = os.path.join(tempfile.mkdtemp(), "sources.db")
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import app.main as m
|
||||
m.DB_PATH = os.environ["DB_PATH"]
|
||||
|
||||
conn = m.get_db()
|
||||
conn.execute("INSERT OR REPLACE INTO members (email, slug, active, source) VALUES (?,?,?,?)",
|
||||
("a@example.org", "slug-a", 1, "oc-incognito"))
|
||||
conn.execute("INSERT OR REPLACE INTO members (email, slug, active, source) VALUES (?,?,?,?)",
|
||||
("b@example.org", "slug-b", 1, "oc-incognito"))
|
||||
conn.commit(); conn.close()
|
||||
|
||||
m.fetch_member_index = lambda: [("a@example.org", "slug-a"), ("other@example.org", "slug-z")]
|
||||
r = asyncio.run(m.derive_member_sources())
|
||||
conn = m.get_db()
|
||||
a = conn.execute("SELECT source, oc_email FROM members WHERE email='a@example.org'").fetchone()
|
||||
b = conn.execute("SELECT source, oc_email FROM members WHERE email='b@example.org'").fetchone()
|
||||
conn.close()
|
||||
print(" flipped:", r["flipped"], "| a:", tuple(a), "| b:", tuple(b))
|
||||
assert tuple(a) == ("oc", "a@example.org"), "visible email must flip the source and record it"
|
||||
assert tuple(b) == ("oc-incognito", None), "a profile still hiding its email stays incognito"
|
||||
print("DERIVE SOURCES OK: flips only where the profile now shows an email")
|
||||
Reference in new issue
Block a user