This commit is contained in:
ponzischeme89
2026-08-20 15:06:00 +12:00
parent 549f9c5eed
commit f1164db2c5
52 changed files with 5441 additions and 158 deletions
+19
View File
@@ -24,6 +24,7 @@ type requestIdentity struct {
component string
userID string
user string
viewer string
device string
client string
protocol string
@@ -73,6 +74,21 @@ func identify(ctx context.Context, sess store.Session) {
}
}
// identifyViewer names the person watching, where that is somebody other than the account
// itself. A main viewer is deliberately not recorded: its name is already the "user" field,
// and printing it twice on every line would say nothing.
func identifyViewer(ctx context.Context, viewer store.Viewer) {
identity := identityFrom(ctx)
if identity == nil || viewer.IsMain() {
return
}
if viewer.Name != "" {
identity.viewer = viewer.Name
} else {
identity.viewer = viewer.ID
}
}
func (i *requestIdentity) attrs() []any {
if i == nil {
return nil
@@ -124,6 +140,9 @@ func (i *requestIdentity) viewerAttrs() []any {
if i.user != "" {
attrs = append(attrs, "user", i.user)
}
if i.viewer != "" {
attrs = append(attrs, "viewer", i.viewer)
}
if i.device != "" {
attrs = append(attrs, "device", i.device)
}