Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

nnhuyhoang
Copy link
Contributor

What's this PR do?

  • [x]

Comment on lines 75 to 81
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"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove json tag

return
}
c.JSON(http.StatusOK, view.CreateResponse(messages, nil, nil, nil, ""))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed linter

c.JSON(http.StatusInternalServerError, view.CreateResponse[any](nil, nil, err, nil, ""))
return
}
c.JSON(http.StatusOK, view.CreateResponse(messages, nil, nil, nil, ""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define view

Comment on lines 780 to 794
// 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]
Copy link
Collaborator

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{
Copy link
Member

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

Copy link
Contributor Author

@nnhuyhoang nnhuyhoang Oct 8, 2024

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"),
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants