@@ -34,6 +34,7 @@ import (
3434 "os"
3535 "path/filepath"
3636 "strconv"
37+ "sync"
3738 "time"
3839 "unicode"
3940 "unicode/utf8"
@@ -176,6 +177,13 @@ func main() {
176177
177178 roomRouter := publicRouter .Group ("/room/:roomID/" )
178179 {
180+ roomRouter .GET ("/$:eventID" , func (c * gin.Context ) {
181+ eventID := c .Param ("eventID" )
182+ roomID := c .Param ("roomID" )
183+
184+ c .Redirect (http .StatusTemporaryRedirect , "/room/" + roomID + "/?anchor=$" + eventID + "&highlight" )
185+ })
186+
179187 // Load room worker into request object so that we can do any clean up etc here
180188 roomRouter .Use (func (c * gin.Context ) {
181189 roomID := c .Param ("roomID" )
@@ -244,6 +252,7 @@ func main() {
244252 }
245253
246254 events := mxclient .ReverseEventsCopy (jobResult .Events )
255+ _ , highlight := c .GetQuery ("highlight" )
247256
248257 templates .WritePageTemplate (c .Writer , & templates.RoomChatPage {
249258 RoomInfo : jobResult .RoomInfo ,
@@ -258,6 +267,7 @@ func main() {
258267
259268 Sanitizer : sanitizerFn ,
260269 HomeserverBaseURL : client .HomeserverURL .String (),
270+ Highlight : highlight ,
261271 })
262272 })
263273
@@ -362,13 +372,17 @@ func startPublicRoomListTimer(worldReadableRooms *mxclient.WorldReadableRooms) {
362372 }
363373}
364374
365- const LazyForwardPaginateRooms = time .Minute
375+ const LazyForwardPaginateRooms = 2 * time .Minute
366376
367377func startForwardPaginator (workers * Workers ) {
368- t := time .NewTicker (LazyForwardPaginateRooms )
378+ //t := time.NewTicker(LazyForwardPaginateRooms)
379+ wg := sync.WaitGroup {}
369380 for {
370- <- t .C
381+ //<-t.C
382+ time .Sleep (LazyForwardPaginateRooms )
383+ wg .Add (int (workers .numWorkers ))
371384 log .Info ("Forward paginating all loaded rooms" )
372- workers .JobForAllWorkers (RoomForwardPaginateJob {})
385+ workers .JobForAllWorkers (RoomForwardPaginateJob {& wg })
386+ wg .Wait ()
373387 }
374388}
0 commit comments