feat(social): add friends, private chats, inbox and music sharing
ci / module boundaries / boundaries (push) Successful in 7s
ci / api / api (push) Successful in 1m9s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m8s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m23s
ci / db / db (push) Successful in 2m29s
ci / ts / ts (packages + web) (push) Successful in 2m55s

This commit is contained in:
mrleo1nid committed 2026-10-23 03:19:29 +03:00
1 parent f1528de948
commit 0a05bfe2cd
43 files changed
+2828 -389

No files matched your search

@@ -0,0 +1,40 @@
package social
import (
"context"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"pipu/api/internal/api/gen"
"pipu/api/internal/auth"
"strings"
"testing"
)
func TestMessageValidation(t *testing.T) {
id := uuid.New()
for _, m := range []gen.SendDirectMessage{
{Id: id, Text: " \n ", AttachmentKind: "none"},
{Text: "hello", AttachmentKind: "none"},
{Id: id, Text: strings.Repeat("я", 4001), AttachmentKind: "none"},
{Id: id, Text: "hello", AttachmentKind: "url", AttachmentId: &id},
{Id: id, AttachmentKind: "playlist"},
{Id: id, Text: "hello", AttachmentKind: "none", AttachmentId: &id},
} {
require.Error(t, validateMessage(m))
}
require.NoError(t, validateMessage(gen.SendDirectMessage{Id: id, Text: strings.Repeat("я", 4000), AttachmentKind: "none"}))
require.NoError(t, validateMessage(gen.SendDirectMessage{Id: id, AttachmentKind: "track", AttachmentId: &id}))
}
func TestHandlersRequireIdentityAndRejectSelf(t *testing.T) {
h := &Handler{}
_, e := h.GetSocial(context.Background(), gen.GetSocialRequestObject{})
require.Error(t, e)
id := uuid.New()
ctx := auth.WithPrincipal(context.Background(), auth.Principal{UserID: id})
_, e = h.SocialAction(ctx, gen.SocialActionRequestObject{Body: &gen.SocialAction{Action: "request", TargetId: id}})
require.Error(t, e)
_, e = h.SendDirectMessage(ctx, gen.SendDirectMessageRequestObject{PeerId: id})
require.Error(t, e)
_, e = h.SearchPeople(ctx, gen.SearchPeopleRequestObject{Params: gen.SearchPeopleParams{Q: " "}})
require.Error(t, e)
}