Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged. Assisted-by: OpenCode:DeepSeek-V4.1-Flash
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package websocket
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gotea.dev/models/db"
|
|
issues_model "gotea.dev/models/issues"
|
|
user_model "gotea.dev/models/user"
|
|
"gotea.dev/modules/log"
|
|
"gotea.dev/modules/setting"
|
|
"gotea.dev/modules/util"
|
|
"gotea.dev/services/convert"
|
|
)
|
|
|
|
const eventStopwatches = "stopwatches" // keep in sync with web_src/js/types.ts
|
|
|
|
func (n *wsNotifier) StopwatchChanged(ctx context.Context, user *user_model.User) {
|
|
publishUserEvent(user.ID, func() []byte { return stopwatchesEvent(ctx, user) })
|
|
}
|
|
|
|
func stopwatchesEvent(ctx context.Context, user *user_model.User) []byte {
|
|
if !setting.Service.EnableTimetracking {
|
|
return nil
|
|
}
|
|
sws, err := issues_model.GetUserStopwatches(ctx, user.ID, db.ListOptions{})
|
|
if err != nil {
|
|
log.Error("websocket: GetUserStopwatches %d: %v", user.ID, err)
|
|
return nil
|
|
}
|
|
apiStopWatches, err := convert.ToStopWatches(ctx, user, sws)
|
|
if err != nil {
|
|
if !issues_model.IsErrIssueNotExist(err) {
|
|
log.Error("websocket: ToStopWatches: %v", err)
|
|
}
|
|
return nil
|
|
}
|
|
return makeEventMessage(eventStopwatches, "", util.SliceNilAsEmpty(apiStopWatches))
|
|
}
|