spark-server/internal/transport/http/handler/friend/follow.go
DESKTOP-L8OUL9F\gfl0034 ce9c7a13aa feat: 互相关注后自动成为好友
一方关注只记关注。双方互关时写入已有双向好友边;取消关注若不再互关只删好友边,不删消息。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-18 21:51:18 +08:00

62 lines
1.1 KiB
Go

package friendhandler
import (
"github.com/gin-gonic/gin"
"spark-server/internal/transport/http/respond"
)
func (h *Handler) GetFollow(c *gin.Context) {
uid, ok := currentUID(c)
if !ok {
return
}
targetID, err := pathUID(c)
if err != nil {
respond.JSONError(c, err)
return
}
out, err := h.friends.GetFollow(c.Request.Context(), uid, targetID)
if err != nil {
respond.JSONError(c, err)
return
}
respond.JSON(c, out)
}
func (h *Handler) Follow(c *gin.Context) {
uid, ok := currentUID(c)
if !ok {
return
}
targetID, err := pathUID(c)
if err != nil {
respond.JSONError(c, err)
return
}
out, err := h.friends.Follow(c.Request.Context(), uid, targetID)
if err != nil {
respond.JSONError(c, err)
return
}
respond.JSON(c, out)
}
func (h *Handler) Unfollow(c *gin.Context) {
uid, ok := currentUID(c)
if !ok {
return
}
targetID, err := pathUID(c)
if err != nil {
respond.JSONError(c, err)
return
}
out, err := h.friends.Unfollow(c.Request.Context(), uid, targetID)
if err != nil {
respond.JSONError(c, err)
return
}
respond.JSON(c, out)
}