Documentation
¶
Index ¶
- Variables
- func RequireAdminOrSecret(rm *roles.Manager, secret string) func(http.HandlerFunc) http.HandlerFunc
- type Converter
- type DeleteEventsRequest
- type DeprovisionData
- type GetEventResponseOC10
- type NotificationTemplate
- type OC10Notification
- type Option
- func Config(c *config.Config) Option
- func GatewaySelector(gatewaySelector pool.Selectable[gateway.GatewayAPIClient]) Option
- func HistoryClient(hc ehsvc.EventHistoryService) Option
- func Logger(log log.Logger) Option
- func Mux(m *chi.Mux) Option
- func RegisteredEvents(e []events.Unmarshaller) Option
- func RoleClient(rs settingssvc.RoleService) Option
- func Store(s store.Store) Option
- func Stream(s events.Stream) Option
- func TraceProvider(tp trace.TracerProvider) Option
- func ValueClient(vs settingssvc.ValueService) Option
- type Options
- type PostEventsRequest
- type UserlogService
- func (ul *UserlogService) DeleteEvents(userid string, evids []string) error
- func (ul *UserlogService) DeleteGlobalEvents(ctx context.Context, evnames []string) error
- func (ul *UserlogService) GetEvents(ctx context.Context, userid string) ([]*ehmsg.Event, error)
- func (ul *UserlogService) GetGlobalEvents(ctx context.Context) (map[string]json.RawMessage, error)
- func (ul *UserlogService) HandleDeleteEvents(w http.ResponseWriter, r *http.Request)
- func (ul *UserlogService) HandleDeleteGlobalEvent(w http.ResponseWriter, r *http.Request)
- func (ul *UserlogService) HandleGetEvents(w http.ResponseWriter, r *http.Request)
- func (ul *UserlogService) HandlePostGlobalEvent(w http.ResponseWriter, r *http.Request)
- func (ul *UserlogService) MemorizeEvents(ch <-chan events.Event)
- func (ul *UserlogService) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ul *UserlogService) StoreGlobalEvent(ctx context.Context, typ string, data map[string]string) error
Constants ¶
This section is empty.
Variables ¶
var ( VirusFound = NotificationTemplate{ Subject: l10n.Template("Virus found"), Message: l10n.Template("Virus found in {resource}. Upload not possible. Virus: {virus}"), } PoliciesEnforced = NotificationTemplate{ Subject: l10n.Template("Policies enforced"), Message: l10n.Template("File {resource} was deleted because it violates the policies"), } Subject: l10n.Template("Space shared"), Message: l10n.Template("{user} added you to Space {space}"), } Subject: l10n.Template("Removed from Space"), Message: l10n.Template("{user} removed you from Space {space}"), } SpaceDisabled = NotificationTemplate{ Subject: l10n.Template("Space disabled"), Message: l10n.Template("{user} disabled Space {space}"), } SpaceDeleted = NotificationTemplate{ Subject: l10n.Template("Space deleted"), Message: l10n.Template("{user} deleted Space {space}"), } SpaceMembershipExpired = NotificationTemplate{ Subject: l10n.Template("Membership expired"), Message: l10n.Template("Access to Space {space} lost"), } Subject: l10n.Template("Resource shared"), Message: l10n.Template("{user} shared {resource} with you"), } Subject: l10n.Template("Resource unshared"), Message: l10n.Template("{user} unshared {resource} with you"), } Subject: l10n.Template("Share expired"), Message: l10n.Template("Access to {resource} expired"), } PlatformDeprovision = NotificationTemplate{ 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."), } )
the available templates
var HeaderAcceptLanguage = "Accept-Language"
HeaderAcceptLanguage is the header where the client can set the locale
Functions ¶
func RequireAdminOrSecret ¶
func RequireAdminOrSecret(rm *roles.Manager, secret string) func(http.HandlerFunc) http.HandlerFunc
RequireAdminOrSecret middleware allows only requests if the requesting user is an admin or knows the static secret
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter is responsible for converting eventhistory events to OC10Notifications
func NewConverter ¶
func NewConverter(ctx context.Context, loc string, gatewaySelector pool.Selectable[gateway.GatewayAPIClient], name, translationPath, defaultLanguage string) *Converter
NewConverter returns a new Converter
func (*Converter) ConvertEvent ¶
func (c *Converter) ConvertEvent(eventid string, event interface{}) (OC10Notification, error)
ConvertEvent converts an eventhistory event to an OC10Notification
func (*Converter) ConvertGlobalEvent ¶
func (c *Converter) ConvertGlobalEvent(typ string, data json.RawMessage) (OC10Notification, error)
ConvertGlobalEvent converts a global event to an OC10Notification
type DeleteEventsRequest ¶
type DeleteEventsRequest struct {
IDs []string `json:"ids"`
}
DeleteEventsRequest is the expected body for the delete request
type DeprovisionData ¶
type DeprovisionData struct {
// The deprovision date
DeprovisionDate time.Time `json:"deprovision_date"`
// The Format of the deprvision date
DeprovisionFormat string
// The user who stored the deprovision message
Deprovisioner string
}
DeprovisionData is the data needed for the deprovision global event
type GetEventResponseOC10 ¶
type GetEventResponseOC10 struct {
OCS struct {
Meta struct {
Message string `json:"message"`
Status string `json:"status"`
StatusCode int `json:"statuscode"`
} `json:"meta"`
Data []OC10Notification `json:"data"`
} `json:"ocs"`
}
GetEventResponseOC10 is the response from GET events endpoint in oc10 style
type NotificationTemplate ¶
NotificationTemplate is the data structure for the notifications
type OC10Notification ¶
type OC10Notification struct {
EventID string `json:"notification_id"`
Service string `json:"app"`
UserName string `json:"user"`
Timestamp string `json:"datetime"`
ResourceID string `json:"object_id"`
ResourceType string `json:"object_type"`
Subject string `json:"subject"`
SubjectRaw string `json:"subjectRich"`
Message string `json:"message"`
MessageRaw string `json:"messageRich"`
MessageDetails map[string]interface{} `json:"messageRichParameters"`
}
OC10Notification is the oc10 style representation of an event some fields are left out for simplicity
type Option ¶
type Option func(*Options)
Option for the userlog service
func GatewaySelector ¶
func GatewaySelector(gatewaySelector pool.Selectable[gateway.GatewayAPIClient]) Option
GatewaySelector adds a grpc client selector for the gateway service
func HistoryClient ¶
func HistoryClient(hc ehsvc.EventHistoryService) Option
HistoryClient adds a grpc client for the eventhistory service
func RegisteredEvents ¶
func RegisteredEvents(e []events.Unmarshaller) Option
RegisteredEvents registers the events the service should listen to
func RoleClient ¶
func RoleClient(rs settingssvc.RoleService) Option
RoleClient adds a grpc client for the role service
func TraceProvider ¶
func TraceProvider(tp trace.TracerProvider) Option
TraceProvider adds a tracer provider for the userlog service
func ValueClient ¶
func ValueClient(vs settingssvc.ValueService) Option
ValueClient adds a grpc client for the value service
type Options ¶
type Options struct {
Logger log.Logger
Stream events.Stream
Mux *chi.Mux
Store store.Store
Config *config.Config
HistoryClient ehsvc.EventHistoryService
GatewaySelector pool.Selectable[gateway.GatewayAPIClient]
ValueClient settingssvc.ValueService
RoleClient settingssvc.RoleService
RegisteredEvents []events.Unmarshaller
TraceProvider trace.TracerProvider
}
Options for the userlog service
type PostEventsRequest ¶
type PostEventsRequest struct {
// the event type, e.g. "deprovision"
Type string `json:"type"`
// arbitray data for the event
Data map[string]string `json:"data"`
}
PostEventsRequest is the expected body for the post request
type UserlogService ¶
type UserlogService struct {
// contains filtered or unexported fields
}
UserlogService is the service responsible for user activities
func NewUserlogService ¶
func NewUserlogService(opts ...Option) (*UserlogService, error)
NewUserlogService returns an EventHistory service
func (*UserlogService) DeleteEvents ¶
func (ul *UserlogService) DeleteEvents(userid string, evids []string) error
DeleteEvents will delete the specified events
func (*UserlogService) DeleteGlobalEvents ¶
func (ul *UserlogService) DeleteGlobalEvents(ctx context.Context, evnames []string) error
DeleteGlobalEvents will delete the specified event
func (*UserlogService) GetEvents ¶
GetEvents allows retrieving events from the eventhistory by userid
func (*UserlogService) GetGlobalEvents ¶
func (ul *UserlogService) GetGlobalEvents(ctx context.Context) (map[string]json.RawMessage, error)
GetGlobalEvents will return all global events
func (*UserlogService) HandleDeleteEvents ¶
func (ul *UserlogService) HandleDeleteEvents(w http.ResponseWriter, r *http.Request)
HandleDeleteEvents is the DELETE handler for events
func (*UserlogService) HandleDeleteGlobalEvent ¶
func (ul *UserlogService) HandleDeleteGlobalEvent(w http.ResponseWriter, r *http.Request)
HandleDeleteGlobalEvent is the DELETE handler for global events
func (*UserlogService) HandleGetEvents ¶
func (ul *UserlogService) HandleGetEvents(w http.ResponseWriter, r *http.Request)
HandleGetEvents is the GET handler for events
func (*UserlogService) HandlePostGlobalEvent ¶
func (ul *UserlogService) HandlePostGlobalEvent(w http.ResponseWriter, r *http.Request)
HandlePostGlobaelEvent is the POST handler for global events
func (*UserlogService) MemorizeEvents ¶
func (ul *UserlogService) MemorizeEvents(ch <-chan events.Event)
MemorizeEvents stores eventIDs a user wants to receive
func (*UserlogService) ServeHTTP ¶
func (ul *UserlogService) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP fulfills Handler interface
func (*UserlogService) StoreGlobalEvent ¶
func (ul *UserlogService) StoreGlobalEvent(ctx context.Context, typ string, data map[string]string) error
StoreGlobalEvent will store a global event that will be returned with each `GetEvents` request