feat(social): add listening activity, shared rooms and modern chat
ci / api / api (push) Canceled after 0s
ci / module boundaries / boundaries (push) Canceled after 0s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Canceled after 11m29s
ci / db / db (push) Canceled after 11m22s
ci / mobile / mobile (Metro-бандл Android) (push) Canceled after 6m43s
ci / recommender / recommender (push) Canceled after 6m47s
ci / ts / ts (packages + web) (push) Canceled after 1s
ci / api / api (push) Canceled after 0s
ci / module boundaries / boundaries (push) Canceled after 0s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Canceled after 11m29s
ci / db / db (push) Canceled after 11m22s
ci / mobile / mobile (Metro-бандл Android) (push) Canceled after 6m43s
ci / recommender / recommender (push) Canceled after 6m47s
ci / ts / ts (packages + web) (push) Canceled after 1s
This commit is contained in:
1 parent
0a05bfe2cd
commit
11a16cd023
59 files changed
+5022
-542
No files matched your search
@@ -13,9 +13,18 @@ import (
|
||||
"pipu/api/internal/platform/apperr"
|
||||
)
|
||||
|
||||
type Handler struct{ store *Store }
|
||||
type ActivityPlaylistReader interface {
|
||||
ReadSocialPlaylist(context.Context, uuid.UUID) (gen.Playlist, error)
|
||||
}
|
||||
|
||||
func NewHandler(pool *pgxpool.Pool) *Handler { return &Handler{store: &Store{pool: pool}} }
|
||||
type Handler struct {
|
||||
store *Store
|
||||
playlists ActivityPlaylistReader
|
||||
}
|
||||
|
||||
func NewHandler(pool *pgxpool.Pool, playlists ActivityPlaylistReader) *Handler {
|
||||
return &Handler{store: &Store{pool: pool}, playlists: playlists}
|
||||
}
|
||||
func userID(ctx context.Context) (uuid.UUID, error) {
|
||||
p, ok := auth.PrincipalFrom(ctx)
|
||||
if !ok {
|
||||
@@ -71,10 +80,20 @@ func (h *Handler) GetDirectMessages(ctx context.Context, r gen.GetDirectMessages
|
||||
if r.PeerId == uuid.Nil || r.PeerId == id || (r.Params.Before != nil && *r.Params.Before < 1) {
|
||||
return nil, invalid()
|
||||
}
|
||||
v, e := h.store.messages(ctx, id, r.PeerId, r.Params.Before)
|
||||
q := ""
|
||||
if r.Params.Q != nil {
|
||||
q = strings.TrimSpace(*r.Params.Q)
|
||||
}
|
||||
if utf8.RuneCountInString(q) > 100 {
|
||||
return nil, invalid()
|
||||
}
|
||||
v, e := h.store.messagePage(ctx, id, r.PeerId, r.Params.Before, q)
|
||||
return gen.GetDirectMessages200JSONResponse(v), e
|
||||
}
|
||||
func validateMessage(m gen.SendDirectMessage) error {
|
||||
if m.ReplyTo != nil && *m.ReplyTo == uuid.Nil {
|
||||
return invalid()
|
||||
}
|
||||
if m.Id == uuid.Nil || utf8.RuneCountInString(m.Text) > 4000 {
|
||||
return invalid()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user