-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2024 data reorganization: ctx.db #93
Comments
I'm on the verge of convincing myself to not give users direct write access to anything under The benefits would be both increased auditability (continuing to be able to log who did what) and stricter/easier value validation (in Python, near the code where the value is used, versus in Rule language, in an entirely separate package). This could also allow me to eliminate the |
Potential new hierarchy:
|
New year (technically new decade!), new data reorganization. I'm going to end up undoing a whole lot of stuff.
The ctx object will get yet another data storage field (in addition to ctx.user, ctx.userinfo, and ctx.bot.multibot.conf):
ctx.db
.(At least
ctx.userinfo
and maybectx.bot.multibot.conf
will eventually go away.)There will be a new package: metabot.db. It will be pluggable, like metabot.calendars.google:
There will be three components:
corresponding to a new, Cloud Firestore-friendly config hierarchy:
db.user.name
/users/{userid}/info/self.name
db.user.timezone
/users/{userid}/conf/self.timezone
db.bot.name
/bots/{botid}/info/self.name
db.bot.token
/bots/{botid}/conf/self.token
db.chat.name
/bots/{botid}/info/{chatid}.name
db.chat.timezone
/bots/{botid}/conf/{chatid}.timezone
Users will have direct API access to the Firestore db, using rules to give them read access to
/users/{userid}/*/*
(and/bots/{botid}/*/*
for bots for which they are an admin) and write access to/users/{userid}/conf/*
(and/bots/{botid}/conf/*
).When they interact with the bot to request settings, it will generate a custom auth token with the
uid
set to their Telegram userid, then generate a link to something likehttps://nmlorg.github.io/metabot/db.html#{authtoken}/{botid}
.(Or maybe
db.html#{authtoken}/bots/{botid}
, allowing for direct navigation todb.html#{authtoken}/users/{userid}
, but generating a direct link to a specific group chat would be awkward (db.html#{authtoken}/bots/{botid}/info/{chatid}
that also implies/bots/{botid}/conf/{chatid}
?). It might be better to stick to something like/{botid}
,/{botid}/{chatid}
, and maybe just/self
to directly access their own settings.)The text was updated successfully, but these errors were encountered: