-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{- $parent := .QueryParam "parent" -}} | ||
{{- $name := .QueryParam "name" -}} | ||
{{- $stateID := .QueryParam "stateId" -}} | ||
|
||
<div class="page" hx-get="/admin/tags/index" hx-trigger="refreshPage from:window"> | ||
|
||
{{template "menubar" .}} | ||
|
||
<button hx-post="/admin/index-all-streams" hx-swap="none" hx-push-url="false">Index All Streams</button> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
templateId:admin-search | ||
templateRole:admin | ||
model:search | ||
extends: ["admin-common"] | ||
containedBy:["admin"] | ||
label:Search | ||
description: Manage Search Engine Settings | ||
|
||
actions: { | ||
index: {do:"view-html"} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package consumer | ||
|
||
import ( | ||
"github.com/EmissarySocial/emissary/domain" | ||
"github.com/benpate/derp" | ||
"github.com/benpate/remote" | ||
"github.com/benpate/rosetta/mapof" | ||
"github.com/benpate/turbine/queue" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
func IndexAllStreams(factory *domain.Factory, args mapof.Any) queue.Result { | ||
|
||
const location = "consumer.IndexAllStreams" | ||
|
||
streamService := factory.Stream() | ||
|
||
allStreams, err := streamService.RangeAll() | ||
|
||
if err != nil { | ||
return queue.Error(derp.Wrap(err, location, "Error retrieving Streams")) | ||
} | ||
|
||
for summary := range allStreams { | ||
|
||
log.Debug().Str("url", summary.URL).Msg("Indexing Stream") | ||
transaction := remote.Post(summary.URL + "/search-index") | ||
|
||
if err := transaction.Send(); err != nil { | ||
if !derp.IsClientError(err) { | ||
return queue.Error(derp.Wrap(err, location, "Error sending request")) | ||
} | ||
} | ||
} | ||
|
||
return queue.Success() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package handler | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/EmissarySocial/emissary/domain" | ||
"github.com/benpate/derp" | ||
"github.com/benpate/rosetta/mapof" | ||
"github.com/benpate/steranko" | ||
"github.com/benpate/turbine/queue" | ||
) | ||
|
||
// IndexAllStreams is a handler function that triggers the IndexAllStreams queue task. | ||
// It can only be called by an authenticated administrator. | ||
func IndexAllStreams(ctx *steranko.Context, factory *domain.Factory) error { | ||
|
||
// Verify that this is an Administrator | ||
authorization := getAuthorization(ctx) | ||
|
||
if !authorization.DomainOwner { | ||
return derp.NewForbiddenError("handler.IndexAllStreams", "Only administrators can call this method") | ||
} | ||
|
||
// Create the Index task | ||
task := queue.NewTask("IndexAllStreams", mapof.Any{ | ||
"host": ctx.Request().Host, | ||
}) | ||
|
||
// Execute the task in the background | ||
if err := factory.Queue().Publish(task); err != nil { | ||
return derp.Wrap(err, "handler.IndexAllStreams", "Error publishing task") | ||
} | ||
|
||
// Success. | ||
return ctx.NoContent(http.StatusOK) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters