From ea02bd91520b877e75dead6c1c42094674023f1b Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 22 Sep 2025 15:19:34 +0100 Subject: [PATCH] appview/models: move db.Collaborator into models Signed-off-by: oppiliappan --- appview/db/collaborators.go | 19 ++----------------- appview/models/collaborator.go | 21 +++++++++++++++++++++ appview/repo/repo.go | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 appview/models/collaborator.go diff --git a/appview/db/collaborators.go b/appview/db/collaborators.go index cf3b2ceb..77156610 100644 --- a/appview/db/collaborators.go +++ b/appview/db/collaborators.go @@ -3,26 +3,11 @@ package db import ( "fmt" "strings" - "time" - "github.com/bluesky-social/indigo/atproto/syntax" + "tangled.org/core/appview/models" ) -type Collaborator struct { - // identifiers for the record - Id int64 - Did syntax.DID - Rkey string - - // content - SubjectDid syntax.DID - RepoAt syntax.ATURI - - // meta - Created time.Time -} - -func AddCollaborator(e Execer, c Collaborator) error { +func AddCollaborator(e Execer, c models.Collaborator) error { _, err := e.Exec( `insert into collaborators (did, rkey, subject_did, repo_at) values (?, ?, ?, ?);`, c.Did, c.Rkey, c.SubjectDid, c.RepoAt, diff --git a/appview/models/collaborator.go b/appview/models/collaborator.go new file mode 100644 index 00000000..fa80311d --- /dev/null +++ b/appview/models/collaborator.go @@ -0,0 +1,21 @@ +package models + +import ( + "time" + + "github.com/bluesky-social/indigo/atproto/syntax" +) + +type Collaborator struct { + // identifiers for the record + Id int64 + Did syntax.DID + Rkey string + + // content + SubjectDid syntax.DID + RepoAt syntax.ATURI + + // meta + Created time.Time +} diff --git a/appview/repo/repo.go b/appview/repo/repo.go index 58516f94..85bc6c0e 100644 --- a/appview/repo/repo.go +++ b/appview/repo/repo.go @@ -1567,7 +1567,7 @@ func (rp *Repo) AddCollaborator(w http.ResponseWriter, r *http.Request) { return } - err = db.AddCollaborator(tx, db.Collaborator{ + err = db.AddCollaborator(tx, models.Collaborator{ Did: syntax.DID(currentUser.Did), Rkey: rkey, SubjectDid: collaboratorIdent.DID, -- 2.51.2