Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

lazily fetch messages in chat #5114

Closed
wants to merge 2 commits into from
Closed

Conversation

ryanfkeepers
Copy link
Contributor

once we're past kopia assits, the chat can
download all of its messages and store them in the body uploded to kopia.


Does this PR need a docs update or release note?

  • ⛔ No

Type of change

  • 🌻 Feature

Issue(s)

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@ryanfkeepers ryanfkeepers added backup chats 1:1 chats within teams labels Jan 24, 2024
@ryanfkeepers ryanfkeepers self-assigned this Jan 24, 2024
Copy link
Contributor

aviator-app bot commented Jan 24, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was closed without merging. If you still want to merge this PR, re-open it.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

)

if lastMsgPreview != nil {
preview, _, err = getChatMessageContentPreview(lastMsgPreview, noAttachments{})
Copy link
Contributor

@HiteshRepo HiteshRepo Jan 26, 2024

Choose a reason for hiding this comment

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

Suggested change
preview, _, err = getChatMessageContentPreview(lastMsgPreview, noAttachments{})
preview, _, err = getChatMessageContentPreview(lastMsgPreview, nil)

return str.Preview(content, 128), origSize, clues.Stack(err).OrNil()
}

func stripChatMessageHTML(msg models.ChatMessageable) (string, int64, error) {
func stripChatMessageHTML(msg getBodyer, atts getAttachmentser) (string, int64, error) {
Copy link
Contributor

@HiteshRepo HiteshRepo Jan 26, 2024

Choose a reason for hiding this comment

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

Suggested change
func stripChatMessageHTML(msg getBodyer, atts getAttachmentser) (string, int64, error) {
func stripChatMessageHTML(msg getBodyer, atts []models.ChatMessageAttachmentable) (string, int64, error)
{

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea!

@@ -256,7 +272,7 @@ func stripChatMessageHTML(msg models.ChatMessageable) (string, int64, error) {

origSize = int64(len(content))

content = replaceAttachmentMarkup(content, msg.GetAttachments())
content = replaceAttachmentMarkup(content, atts.GetAttachments())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
content = replaceAttachmentMarkup(content, atts.GetAttachments())
content = replaceAttachmentMarkup(content, atts)

@@ -162,7 +162,7 @@ func channelMessageInfo(
modTime = lastReplyAt
}

preview, contentLen, err := getChatMessageContentPreview(msg)
preview, contentLen, err := getChatMessageContentPreview(msg, msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
preview, contentLen, err := getChatMessageContentPreview(msg, msg)
preview, contentLen, err := getChatMessageContentPreview(msg, msg.GetAttachments())

@@ -180,7 +180,7 @@ func channelMessageInfo(
var lr details.ChannelMessageInfo

if lastReply != nil {
preview, contentLen, err = getChatMessageContentPreview(lastReply)
preview, contentLen, err = getChatMessageContentPreview(lastReply, lastReply)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
preview, contentLen, err = getChatMessageContentPreview(lastReply, lastReply)
preview, contentLen, err = getChatMessageContentPreview(lastReply, lastReply.GetAttachments())

Copy link
Contributor

@HiteshRepo HiteshRepo left a comment

Choose a reason for hiding this comment

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

Looks good.
I feel we do not need below (hence suggested changes):

// a hack for fulfilling getAttachmentser when the model doesn't
// provide GetAttachments()
type noAttachments struct{}

func (noAttachments) GetAttachments() []models.ChatMessageAttachmentable {
	return []models.ChatMessageAttachmentable{}
}

type getAttachmentser interface {
	GetAttachments() []models.ChatMessageAttachmentable
}

@ryanfkeepers ryanfkeepers force-pushed the 5062-chats-backup-v0-6 branch 2 times, most recently from 3c5dfe0 to dfa9787 Compare January 29, 2024 23:24
Base automatically changed from 5062-chats-backup-v0-6 to 5062-chats-backup-v0-5 January 30, 2024 02:30
Base automatically changed from 5062-chats-backup-v0-5 to 5062-chats-backup-v0-4 January 30, 2024 02:30
Base automatically changed from 5062-chats-backup-v0-4 to 5062-chats-backup-v0-3 January 30, 2024 02:30
Base automatically changed from 5062-chats-backup-v0-3 to 5062-chats-backup-v0 January 30, 2024 02:32
@ryanfkeepers ryanfkeepers force-pushed the 5062-chats-backup-v0 branch 2 times, most recently from ba1ce0f to 4146bff Compare January 30, 2024 19:21
Base automatically changed from 5062-chats-backup-v0 to main January 30, 2024 20:04
once we're past kopia assits, the chat can
download all of its messages and store them in the body
uploded to kopia.
details wasn't properly listing backed up items. This fixes the details
display, and contains some code clean-up that occurred along the way.
Copy link

sonarcloud bot commented Feb 15, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backup chats 1:1 chats within teams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants