Skip to main content
Glama
Southclaws

Storyden

by Southclaws
create.go1.63 kB
package reply import ( "context" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fctx" "github.com/Southclaws/fault/fmsg" "github.com/Southclaws/opt" "github.com/rs/xid" "github.com/Southclaws/storyden/app/resources/account" "github.com/Southclaws/storyden/app/resources/message" "github.com/Southclaws/storyden/app/resources/post" "github.com/Southclaws/storyden/app/resources/post/reply" ) func (s *Mutator) Create( ctx context.Context, authorID account.AccountID, parentID post.ID, partial Partial, ) (*reply.Reply, error) { if content, ok := partial.Content.Get(); ok { if err := s.cpm.CheckContent(ctx, content); err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } } opts := partial.Opts() p, err := s.replyWriter.Create(ctx, authorID, parentID, opts...) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx), fmsg.With("failed to create reply post in thread")) } pref, err := s.replyQuerier.Probe(ctx, p.ID) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } if err := s.cache.Invalidate(ctx, xid.ID(pref.RootPostID)); err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } replyToAuthorID := opt.Map(p.ReplyTo, func(r reply.Reply) account.AccountID { return r.Author.ID }) replyToReplyID := opt.Map(p.ReplyTo, func(r reply.Reply) post.ID { return r.ID }) s.bus.Publish(ctx, &message.EventThreadReplyCreated{ ThreadID: p.RootPostID, ReplyID: p.ID, ThreadAuthorID: p.RootAuthor.ID, ReplyAuthorID: authorID, ReplyToAuthorID: replyToAuthorID, ReplyToTargetID: replyToReplyID, }) return p, nil }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server