Skip to content

Commit

Permalink
Add ability to post permalinks (#468)
Browse files Browse the repository at this point in the history
* Add ability to post permalinks

Also enabled the feature in deployments

* Fix case of when post is not found
  • Loading branch information
agnivade authored Oct 15, 2021
1 parent 689d4e6 commit e503984
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions deployment/terraform/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func (t *Terraform) updateAppConfig(ip string, sshc *ssh.Client, jobServerEnable
cfg.ServiceSettings.EnableLocalMode = model.NewBool(true)
cfg.ServiceSettings.CollapsedThreads = model.NewString(model.CollapsedThreadsDefaultOn)
cfg.ServiceSettings.EnableLinkPreviews = model.NewBool(true)
cfg.ServiceSettings.EnablePermalinkPreviews = model.NewBool(true)
cfg.EmailSettings.SMTPServer = model.NewString(t.output.MetricsServer.PrivateIP)
cfg.EmailSettings.SMTPPort = model.NewString("2500")

Expand Down
19 changes: 19 additions & 0 deletions loadtest/control/simulcontroller/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,25 @@ func createMessage(u user.User, channel *model.Channel, isReply bool) (string, e
message = control.AddLink(message)
}

// 10% of messages will contain a permalink
if rand.Float64() < 0.10 {
post, err := u.Store().RandomPostForChannel(channel.Id)
if err != nil && !errors.Is(err, memstore.ErrPostNotFound) {
return "", err
}
// We ignore in case a post is not found.
if err == nil {
siteURL := u.Store().ClientConfig()["SiteURL"]
team, err := u.Store().CurrentTeam()
if err != nil {
return "", err
}
pl := siteURL + "/" + team.Name + "/pl/" + post.Id

message += " " + pl + " "
}
}

message += genMessage(isReply)
return message, nil
}
Expand Down

0 comments on commit e503984

Please sign in to comment.