diff --git a/go.mod b/go.mod index 0f9854f..1ce4317 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.2 require ( git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8 - git.solsynth.dev/hypernet/passport v0.0.0-20241031144010-d1f1183beb36 + git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174 git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e github.com/fatih/color v1.17.0 github.com/go-playground/validator/v10 v10.22.1 diff --git a/go.sum b/go.sum index 038e985..866add2 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8 h1:fo9WuAXcmx git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI= git.solsynth.dev/hypernet/passport v0.0.0-20241031144010-d1f1183beb36 h1:rzDuXRTCbWJOgfT7bG0cWFcYqbWKnI1aEfiovpXfsdM= git.solsynth.dev/hypernet/passport v0.0.0-20241031144010-d1f1183beb36/go.mod h1:EjUDX5HdTo3J1GfAN5mfDf0JxRspzASj8uysa4V/ow0= +git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174 h1:XplLpEeQOFlZR2/A4YIeh0B/g9//pXg/TXtWrvHDops= +git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174/go.mod h1:EjUDX5HdTo3J1GfAN5mfDf0JxRspzASj8uysa4V/ow0= git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e h1:DtHhMjgxS/spUt/KEdbRFtaVnepI6Vx8pbHdJaNH1hs= git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= diff --git a/pkg/internal/http/api/posts_api.go b/pkg/internal/http/api/posts_api.go index 6654fda..2f12192 100644 --- a/pkg/internal/http/api/posts_api.go +++ b/pkg/internal/http/api/posts_api.go @@ -37,7 +37,7 @@ func universalPostFilter(c *fiber.Ctx, tx *gorm.DB) (*gorm.DB, error) { if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil { return tx, fiber.NewError(fiber.StatusNotFound, err.Error()) } - tx = tx.Where("author_id = ?", author.ID) + tx = tx.Where("publisher_id = ?", author.ID) } if len(c.Query("category")) > 0 { @@ -330,7 +330,7 @@ func pinPost(c *fiber.Ctx) error { user := c.Locals("user").(authm.Account) var res models.Post - if err := database.C.Where("id = ? AND author_id = ?", c.Params("postId"), user.ID).First(&res).Error; err != nil { + if err := database.C.Where("id = ? AND publisher_id = ?", c.Params("postId"), user.ID).First(&res).Error; err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to find post in your posts to pin: %v", err)) } diff --git a/pkg/internal/http/api/publishers_api.go b/pkg/internal/http/api/publishers_api.go index 186e3c8..01be7aa 100644 --- a/pkg/internal/http/api/publishers_api.go +++ b/pkg/internal/http/api/publishers_api.go @@ -25,7 +25,7 @@ func listPinnedPost(c *fiber.Ctx) error { } tx := services.FilterPostDraft(database.C) - tx = tx.Where("author_id = ?", user.ID) + tx = tx.Where("publisher_id = ?", user.ID) tx = tx.Where("pinned_at IS NOT NULL") items, err := services.ListPost(tx, 100, 0, "published_at DESC") diff --git a/pkg/internal/http/api/recommendation_api.go b/pkg/internal/http/api/recommendation_api.go index 6ee3460..908a6c6 100644 --- a/pkg/internal/http/api/recommendation_api.go +++ b/pkg/internal/http/api/recommendation_api.go @@ -74,7 +74,7 @@ func listRecommendationFriends(c *fiber.Ctx) error { return uint(item.GetId()) }) - tx = tx.Where("author_id IN ?", friendList) + tx = tx.Where("publisher_id IN ?", friendList) countTx := tx count, err := services.CountPost(countTx) diff --git a/pkg/internal/http/api/replies_api.go b/pkg/internal/http/api/replies_api.go index 30fed41..c3d812a 100644 --- a/pkg/internal/http/api/replies_api.go +++ b/pkg/internal/http/api/replies_api.go @@ -25,7 +25,7 @@ func listPostReplies(c *fiber.Ctx) error { if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } - tx = tx.Where("author_id = ?", author.ID) + tx = tx.Where("publisher_id = ?", author.ID) } if len(c.Query("category")) > 0 { @@ -68,7 +68,7 @@ func listPostFeaturedReply(c *fiber.Ctx) error { if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } - tx = tx.Where("author_id = ?", author.ID) + tx = tx.Where("publisher_id = ?", author.ID) } if len(c.Query("category")) > 0 { diff --git a/pkg/internal/services/conversations.go b/pkg/internal/services/conversations.go index d694c10..01e6489 100644 --- a/pkg/internal/services/conversations.go +++ b/pkg/internal/services/conversations.go @@ -24,7 +24,7 @@ func GetConversation(start uint, offset, take int, order string, participants [] SELECT p.* FROM %s p - INNER JOIN conversation c ON p.reply_id = c.id AND p.author_id IN (?) + INNER JOIN conversation c ON p.reply_id = c.id AND p.publisher_id IN (?) ) SELECT * FROM conversation ORDER BY %s DESC OFFSET %d LIMIT %d`, table, table, order, offset, take, diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index ffc5d65..186e9d8 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -41,7 +41,7 @@ func FilterPostWithUserContext(tx *gorm.DB, user *authm.Account) *gorm.DB { }) tx = tx.Where( - "(visibility != ? OR (visibility != ? AND author_id IN ? AND author_id NOT IN ?) OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR author_id = ?)", + "(visibility != ? OR (visibility != ? AND publisher_id IN ? AND publisher_id NOT IN ?) OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR publisher_id = ?)", NoneVisibility, FriendsVisibility, allowlist, @@ -91,7 +91,7 @@ func FilterPostWithPublishedAt(tx *gorm.DB, date time.Time) *gorm.DB { } func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB { - return tx.Where("author_id = ? AND is_draft = ?", uid, true) + return tx.Where("publisher_id = ? AND is_draft = ?", uid, true) } func FilterPostDraft(tx *gorm.DB) *gorm.DB {