-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add get discord message logs api #755
base: develop
Are you sure you want to change the base?
Conversation
pkg/model/discord_message.go
Outdated
ID string `json:"id"` | ||
Content string `json:"content"` | ||
AuthorName string `json:"author_name"` | ||
AuthorID string `json:"author_id"` | ||
ChannelID string `json:"channel_id"` | ||
GuildID string `json:"guild_id"` | ||
Timestamp time.Time `json:"timestamp"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove json tag
pkg/handler/discord/discord.go
Outdated
return | ||
} | ||
c.JSON(http.StatusOK, view.CreateResponse(messages, nil, nil, nil, "")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed linter
pkg/handler/discord/discord.go
Outdated
c.JSON(http.StatusInternalServerError, view.CreateResponse[any](nil, nil, err, nil, "")) | ||
return | ||
} | ||
c.JSON(http.StatusOK, view.CreateResponse(messages, nil, nil, nil, "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define view
pkg/handler/discord/discord.go
Outdated
// ListChannelMessageLogs godoc | ||
// @Summary Get list of messages in channel and its thread | ||
// @Description Get list of messages in channel and its thread | ||
// @id ListChannelMessageLogs | ||
// @Tags Discord | ||
// @Accept json | ||
// @Produce json | ||
// @Param discord_channel_id path string true "Channel Discord ID" | ||
// @Param startDate query string true "Start Date" | ||
// @Param endDate query string true "End Date" | ||
// @Success 200 {object} ListResearchTopicResponse | ||
// @Failure 400 {object} ErrorResponse | ||
// @Failure 404 {object} ErrorResponse | ||
// @Failure 500 {object} ErrorResponse | ||
// @Router /discords/{discord_channel_id}/message-logs [get] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be updated
} | ||
|
||
for _, msg := range messages { | ||
messageLogs = append(messageLogs, model.DiscordTextMessageLog{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namnhce @nnhuyhoang
this seems like a potential OOM, since on prod we only have 100MB-ish memory, make sure we dont OOM here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will test on dev with the same amount of messages, if cannot handle them , find another way
// @Router /discords/channels/{discord_channel_id}/message-logs [get] | ||
func (h *handler) ListChannelMessageLogs(c *gin.Context) { | ||
var input = request.GetChannelMessagesInput{ | ||
DiscordChannelID: c.Param("discord_channel_id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nnhuyhoang will this allow client call any discord_channel_id, if yes, gonna reject this for now
please follow up with me about this approach, need to validate/whitelist some channels only
What's this PR do?