API: Add action and user context to indexing events #98

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2023-03-11 14:09:00 +01:00
parent a5f4cce181
commit dcffa2848a
15 changed files with 127 additions and 38 deletions

View File

@@ -105,7 +105,7 @@ func StartImport(router *gin.RouterGroup) {
// Set user UID if known.
if s.UserUID != "" {
opt.UserUID = s.UserUID
opt.UID = s.UserUID
}
// Start import.
@@ -138,8 +138,16 @@ func StartImport(router *gin.RouterGroup) {
msg := i18n.Msg(i18n.MsgImportCompletedIn, elapsed)
event.Success(msg)
event.Publish("import.completed", event.Data{"path": importPath, "seconds": elapsed})
event.Publish("index.completed", event.Data{"path": importPath, "seconds": elapsed})
eventData := event.Data{
"uid": opt.UID,
"action": opt.Action,
"path": importPath,
"seconds": elapsed,
}
event.Publish("import.completed", eventData)
event.Publish("index.completed", eventData)
for _, uid := range f.Albums {
PublishAlbumEvent(EntityUpdated, uid, c)