Settings column and now-playing state table (phase 4, step 1)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m9s
CI / test (push) Successful in 3m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m9s
CI / test (push) Successful in 3m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
federation_settings gains now_playing_mode (off/profile/posts, default off), validated in sharing.update() the same way visibility is. New federation_now_playing table: one row per user, tracking what we've last told the fediverse (profile_key/profile_updated_at, post_key/post_posted_at) - separate from core's now_playing table, which is what's actually playing right now. Verified the migration both ways against the local dev database: full downgrade to base and back up to heads on both branches, not just a single-step round trip. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
7d86bad929
commit
cb8f9c997e
4 files changed
+80
-6
No files matched your search
@@ -21,6 +21,7 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from scrobbler.extensions import db
|
||||
|
||||
VISIBILITIES = ("followers", "unlisted", "public")
|
||||
NOW_PLAYING_MODES = ("off", "profile", "posts")
|
||||
|
||||
|
||||
def utcnow() -> datetime:
|
||||
@@ -44,6 +45,8 @@ class FederationSettings(db.Model):
|
||||
timezone: Mapped[str] = mapped_column(String(64), default="UTC")
|
||||
post_weekly_summary: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
post_milestones: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
# off, profile or posts (posts implies profile too)
|
||||
now_playing_mode: Mapped[str] = mapped_column(String(16), default="off")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=utcnow, onupdate=utcnow
|
||||
@@ -247,3 +250,20 @@ class FederationPendingCheck(db.Model):
|
||||
)
|
||||
since: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
reason: Mapped[str] = mapped_column(String(32), default="scrobble")
|
||||
|
||||
|
||||
class FederationNowPlaying(db.Model):
|
||||
"""What we've last told the fediverse is playing, as opposed to `now_playing` in the
|
||||
core schema, which is what's actually playing. A "key" is `artist\\x1ftrack\\x1f
|
||||
started_at`: playing the same track again later is a new now-playing moment, not a
|
||||
stale repeat, and it doubles as federation_posts.key for the posts side."""
|
||||
|
||||
__tablename__ = "federation_now_playing"
|
||||
|
||||
user_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
profile_key: Mapped[str | None] = mapped_column(String(512))
|
||||
profile_updated_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||
post_key: Mapped[str | None] = mapped_column(String(512))
|
||||
post_posted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||
Reference in new issue
Block a user