-
Notifications
You must be signed in to change notification settings - Fork 32
Attachments & Quotes に対応 #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Attachments & Quotes に対応 #3097
Changes from 1 commit
fb54348
a3f94bc
a514661
89d0a07
dde926a
5512ece
fb9e53a
dd100e9
33cad4a
9016117
6152994
4b0e3e3
4c713b4
b3fa894
63ec275
4e76e48
14eaf76
a822a71
10f3cf1
585fd36
a3bf598
773b305
8490669
1f126ee
48ae919
148da8f
a9d9395
6c8e94b
580661e
a20efd1
49db0cf
a0a81d9
1cdf80f
1bf1052
3121ad8
888c708
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import ( | |
| "github.com/traPtitech/traQ/repository" | ||
| "github.com/traPtitech/traQ/service/channel" | ||
| "github.com/traPtitech/traQ/utils" | ||
| messageParse "github.com/traPtitech/traQ/utils/message" | ||
|
cp-20 marked this conversation as resolved.
Outdated
|
||
| "github.com/traPtitech/traQ/utils/optional" | ||
| ) | ||
|
|
||
|
|
@@ -64,13 +65,43 @@ func (m *manager) get(ctx context.Context, id uuid.UUID) (*message, error) { | |
| return m.cache.Get(ctx, id) | ||
| } | ||
|
|
||
| func (m *manager) GetIn(ctx context.Context, ids []uuid.UUID) ([]Message, error) { | ||
| messages, _, err := m.R.GetMessages(ctx, repository.MessagesQuery{IDIn: optional.From(ids)}) | ||
| func (m *manager) GetIn(ctx context.Context, ids []uuid.UUID, ia bool, iq bool) ([]MessageNew, error) { | ||
| messages, _, err := m.R.GetMessages(ctx, repository.MessagesQuery{IDIn: optional.From(ids), IncludeAttachments: ia, IncludeQuotes: iq}) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| ret := utils.Map(messages, func(m *model.Message) Message { | ||
| return &message{Model: m} | ||
| ret := utils.Map(messages, func(mm *model.Message) MessageNew { | ||
| parseResult := messageParse.Parse(mm.Text) | ||
| pRa := parseResult.Attachments | ||
| aR := []*model.FileMeta{} | ||
| for i := 0; i < len(pRa); i++ { | ||
| attachment, err := m.R.GetFileMeta(ctx, pRa[i]) | ||
| if err != nil { | ||
| break | ||
| } | ||
| aR = append(aR, attachment) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Attachment fetch errors are silently swallowed. On the first 🤖 Prompt for AI Agents |
||
| pRc := parseResult.Citation | ||
| quotes, _, err := m.R.GetMessages(ctx, repository.MessagesQuery{IDIn: optional.From((pRc))}) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| mn := &model.MessageNew{ | ||
| ID: mm.ID, | ||
| UserID: mm.UserID, | ||
| ChannelID: mm.ChannelID, | ||
| Text: mm.Text, | ||
| CreatedAt: mm.CreatedAt, | ||
| UpdatedAt: mm.UpdatedAt, | ||
| DeletedAt: mm.DeletedAt, | ||
| User: mm.User, | ||
| Channel: mm.Channel, | ||
| Stamps: mm.Stamps, | ||
| Pin: mm.Pin, | ||
| Attachments: aR, | ||
| Quotes: quotes, | ||
| } | ||
| return &messageNew{Model: mn} | ||
| }) | ||
| return ret, nil | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.