move more functionality to l10n pkg
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -11,20 +11,18 @@ import (
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
"github.com/go-chi/chi/v5"
|
||||
micrometadata "go-micro.dev/v4/metadata"
|
||||
"go-micro.dev/v4/store"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/cs3org/reva/v2/pkg/utils"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/l10n"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/roles"
|
||||
ehmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/eventhistory/v0"
|
||||
ehsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/eventhistory/v0"
|
||||
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults"
|
||||
"github.com/owncloud/ocis/v2/services/userlog/pkg/config"
|
||||
)
|
||||
|
||||
@@ -343,7 +341,7 @@ func (ul *UserlogService) sendSSE(ctx context.Context, userIDs []string, event e
|
||||
m := make(map[string]events.SendSSE)
|
||||
|
||||
for _, userid := range userIDs {
|
||||
loc := ul.getUserLocale(userid)
|
||||
loc := l10n.MustGetUserLocale(ctx, userid, "", ul.valueClient)
|
||||
if ev, ok := m[loc]; ok {
|
||||
ev.UserIDs = append(m[loc].UserIDs, userid)
|
||||
m[loc] = ev
|
||||
@@ -455,25 +453,6 @@ func (ul *UserlogService) alterGlobalEvents(ctx context.Context, alter func(map[
|
||||
})
|
||||
}
|
||||
|
||||
func (ul *UserlogService) getUserLocale(userid string) string {
|
||||
resp, err := ul.valueClient.GetValueByUniqueIdentifiers(
|
||||
micrometadata.Set(context.Background(), middleware.AccountID, userid),
|
||||
&settingssvc.GetValueByUniqueIdentifiersRequest{
|
||||
AccountUuid: userid,
|
||||
SettingId: defaults.SettingUUIDProfileLanguage,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
ul.log.Error().Err(err).Str("userid", userid).Msg("cannot get users locale")
|
||||
return ""
|
||||
}
|
||||
val := resp.GetValue().GetValue().GetListValue().GetValues()
|
||||
if len(val) == 0 {
|
||||
return ""
|
||||
}
|
||||
return val[0].GetStringValue()
|
||||
}
|
||||
|
||||
func removeExecutant(users []string, executant *user.UserId) []string {
|
||||
var usrs []string
|
||||
for _, u := range users {
|
||||
|
||||
@@ -1,63 +1,62 @@
|
||||
package service
|
||||
|
||||
// Template marks the string as a translatable template
|
||||
func Template(s string) string { return s }
|
||||
import "github.com/owncloud/ocis/v2/ocis-pkg/l10n"
|
||||
|
||||
// the available templates
|
||||
var (
|
||||
VirusFound = NotificationTemplate{
|
||||
Subject: Template("Virus found"),
|
||||
Message: Template("Virus found in {resource}. Upload not possible. Virus: {virus}"),
|
||||
Subject: l10n.Template("Virus found"),
|
||||
Message: l10n.Template("Virus found in {resource}. Upload not possible. Virus: {virus}"),
|
||||
}
|
||||
|
||||
PoliciesEnforced = NotificationTemplate{
|
||||
Subject: Template("Policies enforced"),
|
||||
Message: Template("File {resource} was deleted because it violates the policies"),
|
||||
Subject: l10n.Template("Policies enforced"),
|
||||
Message: l10n.Template("File {resource} was deleted because it violates the policies"),
|
||||
}
|
||||
|
||||
SpaceShared = NotificationTemplate{
|
||||
Subject: Template("Space shared"),
|
||||
Message: Template("{user} added you to Space {space}"),
|
||||
Subject: l10n.Template("Space shared"),
|
||||
Message: l10n.Template("{user} added you to Space {space}"),
|
||||
}
|
||||
|
||||
SpaceUnshared = NotificationTemplate{
|
||||
Subject: Template("Removed from Space"),
|
||||
Message: Template("{user} removed you from Space {space}"),
|
||||
Subject: l10n.Template("Removed from Space"),
|
||||
Message: l10n.Template("{user} removed you from Space {space}"),
|
||||
}
|
||||
|
||||
SpaceDisabled = NotificationTemplate{
|
||||
Subject: Template("Space disabled"),
|
||||
Message: Template("{user} disabled Space {space}"),
|
||||
Subject: l10n.Template("Space disabled"),
|
||||
Message: l10n.Template("{user} disabled Space {space}"),
|
||||
}
|
||||
|
||||
SpaceDeleted = NotificationTemplate{
|
||||
Subject: Template("Space deleted"),
|
||||
Message: Template("{user} deleted Space {space}"),
|
||||
Subject: l10n.Template("Space deleted"),
|
||||
Message: l10n.Template("{user} deleted Space {space}"),
|
||||
}
|
||||
|
||||
SpaceMembershipExpired = NotificationTemplate{
|
||||
Subject: Template("Membership expired"),
|
||||
Message: Template("Access to Space {space} lost"),
|
||||
Subject: l10n.Template("Membership expired"),
|
||||
Message: l10n.Template("Access to Space {space} lost"),
|
||||
}
|
||||
|
||||
ShareCreated = NotificationTemplate{
|
||||
Subject: Template("Resource shared"),
|
||||
Message: Template("{user} shared {resource} with you"),
|
||||
Subject: l10n.Template("Resource shared"),
|
||||
Message: l10n.Template("{user} shared {resource} with you"),
|
||||
}
|
||||
|
||||
ShareRemoved = NotificationTemplate{
|
||||
Subject: Template("Resource unshared"),
|
||||
Message: Template("{user} unshared {resource} with you"),
|
||||
Subject: l10n.Template("Resource unshared"),
|
||||
Message: l10n.Template("{user} unshared {resource} with you"),
|
||||
}
|
||||
|
||||
ShareExpired = NotificationTemplate{
|
||||
Subject: Template("Share expired"),
|
||||
Message: Template("Access to {resource} expired"),
|
||||
Subject: l10n.Template("Share expired"),
|
||||
Message: l10n.Template("Access to {resource} expired"),
|
||||
}
|
||||
|
||||
PlatformDeprovision = NotificationTemplate{
|
||||
Subject: Template("Instance will be shut down and deprovisioned"),
|
||||
Message: Template("Attention! The instance will be shut down and deprovisioned on {date}. Download all your data before that date as no access past that date is possible."),
|
||||
Subject: l10n.Template("Instance will be shut down and deprovisioned"),
|
||||
Message: l10n.Template("Attention! The instance will be shut down and deprovisioned on {date}. Download all your data before that date as no access past that date is possible."),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user