Skip to content

Commit

Permalink
server: respond with success if extension goes to start page
Browse files Browse the repository at this point in the history
  • Loading branch information
l0f3n committed Dec 21, 2023
1 parent dd7ef5d commit e356f99
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wikiweaver-server/cmd/main/wikiweaver-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,16 @@ func handleExtPage(w http.ResponseWriter, r *http.Request) {
return
}

if lobby.StartPage == pageFromExtMessage.Page && extClient.Page == pageFromExtMessage.Page {
log.Printf("extension %s went to start page, responding with success", r.RemoteAddr)
successResponse := PageToExtResponse{
Success: true,
}
SendResponseToExt(w, successResponse)
extClient.mu.Unlock()
return
}

if extClient.Page != pageFromExtMessage.Previous {
log.Printf("refusing to forward page from %s to lobby %s: previous page mismatch: server thinks %s while extension thinks %s", r.RemoteAddr, code, extClient.Page, pageFromExtMessage.Previous)
SendResponseToExt(w, failResponse)
Expand Down Expand Up @@ -912,6 +922,10 @@ func handleExtPage(w http.ResponseWriter, r *http.Request) {
lobby.History = append(lobby.History, pageToWebMessage)
lobby.mu.Unlock()

log.Printf("extension %s sent page: %+v", r.RemoteAddr, pageFromExtMessage)

log.Printf("forwarding page to %d web clients: %+v", len(lobby.WebClients), pageToWebMessage)

lobby.Broadcast(pageToWebMessage)

successResponse := PageToExtResponse{
Expand Down

0 comments on commit e356f99

Please sign in to comment.