service

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MessageResourceCreated    = l10n.Template("{user} added {resource} to {folder}")
	MessageResourceUpdated    = l10n.Template("{user} updated {resource} in {folder}")
	MessageResourceDownloaded = l10n.Template("{resource} was downloaded via public link {token}")
	MessageResourceTrashed    = l10n.Template("{user} deleted {resource} from {folder}")
	MessageResourceMoved      = l10n.Template("{user} moved {resource} to {folder}")
	MessageResourceRenamed    = l10n.Template("{user} renamed {oldResource} to {resource}")
	MessageShareCreated       = l10n.Template("{user} shared {resource} with {sharee}")
	MessageShareUpdated       = l10n.Template("{user} updated {field} for the {resource}")
	MessageShareDeleted       = l10n.Template("{user} removed {sharee} from {resource}")
	MessageLinkCreated        = l10n.Template("{user} shared {resource} via link")
	MessageLinkUpdated        = l10n.Template("{user} updated {field} for a link {token} on {resource}")
	MessageLinkDeleted        = l10n.Template("{user} removed link to {resource}")
	MessageSpaceShared        = l10n.Template("{user} added {sharee} as member of {space}")
	MessageSpaceUnshared      = l10n.Template("{user} removed {sharee} from {space}")

	StrSomeField      = l10n.Template("some field")
	StrPermission     = l10n.Template("permission")
	StrPassword       = l10n.Template("password")
	StrExpirationDate = l10n.Template("expiration date")
	StrDisplayName    = l10n.Template("display name")
	StrDescription    = l10n.Template("description")
)

Translations

Functions

func NewActivity

func NewActivity(message string, ts time.Time, eventID string, vars map[string]interface{}) libregraph.Activity

NewActivity creates a new activity

Types

type ActivityOption

type ActivityOption func(context.Context, gateway.GatewayAPIClient, map[string]interface{}) error

ActivityOption allows setting variables for an activity

func WithOldResource

func WithOldResource(ref *provider.Reference) ActivityOption

WithOldResource sets the oldResource variable for an activity

func WithResource

func WithResource(ref *provider.Reference, addSpace bool, explicitResourceName string) ActivityOption

WithResource sets the resource variable for an activity

func WithSharee

func WithSharee(uid *user.UserId, gid *group.GroupId) ActivityOption

WithSharee sets the sharee variable for an activity

func WithSpace

func WithSpace(spaceid *provider.StorageSpaceId) ActivityOption

WithSpace sets the space variable for an activity

func WithTranslation

func WithTranslation(t *l10n.Translator, locale string, key string, values []string) ActivityOption

WithTranslation sets a variable that translation is needed for

func WithTrashedResource

func WithTrashedResource(ref *provider.Reference, rid *provider.ResourceId) ActivityOption

WithTrashedResource sets the resource variable if the resource is trashed

func WithUser

func WithUser(uid *user.UserId, u *user.User, impersonator *user.User) ActivityOption

WithUser sets the user variable for an Activity

func WithVar

func WithVar(key, id, name string) ActivityOption

WithVar sets a variable for an activity

type ActivitylogService

type ActivitylogService struct {
	// contains filtered or unexported fields
}

ActivitylogService logs events per resource

func New

func New(opts ...Option) (*ActivitylogService, error)

New creates a new ActivitylogService

func (*ActivitylogService) Activities

func (a *ActivitylogService) Activities(rid *provider.ResourceId) ([]RawActivity, error)

Activities returns the activities for the given resource

func (*ActivitylogService) AddActivity

func (a *ActivitylogService) AddActivity(initRef *provider.Reference, eventID string, timestamp time.Time) error

AddActivity adds the activity to the given resource and all its parents

func (*ActivitylogService) AddActivityTrashed

func (a *ActivitylogService) AddActivityTrashed(resourceID *provider.ResourceId, reference *provider.Reference, eventID string, timestamp time.Time) error

AddActivityTrashed adds the activity to given trashed resource and all its former parents

func (*ActivitylogService) AddSpaceActivity

func (a *ActivitylogService) AddSpaceActivity(spaceID *provider.StorageSpaceId, eventID string, timestamp time.Time) error

AddSpaceActivity adds the activity to the given spaceroot

func (*ActivitylogService) GetVars

func (s *ActivitylogService) GetVars(ctx context.Context, opts ...ActivityOption) (map[string]interface{}, error)

GetVars calls other service to gather the required data for the activity variables

func (*ActivitylogService) HandleGetItemActivities

func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *http.Request)

HandleGetItemActivities handles the request to get the activities of an item.

func (*ActivitylogService) RemoveActivities

func (a *ActivitylogService) RemoveActivities(rid *provider.ResourceId, toDelete map[string]struct{}) error

RemoveActivities removes the activities from the given resource

func (*ActivitylogService) RemoveResource

func (a *ActivitylogService) RemoveResource(rid *provider.ResourceId) error

RemoveResource removes the resource from the store

func (*ActivitylogService) Run

func (a *ActivitylogService) Run()

Run runs the service

func (*ActivitylogService) ServeHTTP

func (s *ActivitylogService) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

type Actor

type Actor struct {
	ID          string `json:"id"`
	DisplayName string `json:"displayName"`
}

Actor represents a user

type GetActivitiesResponse

type GetActivitiesResponse struct {
	Activities []libregraph.Activity `json:"value"`
}

GetActivitiesResponse is the response on GET activities requests

type Option

type Option func(*Options)

Option for the activitylog service

func Config

func Config(c *config.Config) Option

Config adds the config for the activitylog 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 Logger

func Logger(log log.Logger) Option

Logger configures a logger for the activitylog service

func Mux

func Mux(m *chi.Mux) Option

Mux defines the muxer for the service

func RegisteredEvents

func RegisteredEvents(e []events.Unmarshaller) Option

RegisteredEvents registers the events the service should listen to

func Store

func Store(store microstore.Store) Option

Store configures the store to use

func Stream

func Stream(s events.Stream) Option

Stream configures an event stream for the clientlog service

func TraceProvider

func TraceProvider(tp trace.TracerProvider) Option

TraceProvider adds a tracer provider for the activitylog 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
	Config           *config.Config
	TraceProvider    trace.TracerProvider
	Stream           events.Stream
	RegisteredEvents []events.Unmarshaller
	Store            microstore.Store
	GatewaySelector  pool.Selectable[gateway.GatewayAPIClient]
	Mux              *chi.Mux
	HistoryClient    ehsvc.EventHistoryService
	ValueClient      settingssvc.ValueService
}

Options for the activitylog service

type RawActivity

type RawActivity struct {
	EventID   string    `json:"event_id"`
	Depth     int       `json:"depth"`
	Timestamp time.Time `json:"timestamp"`
}

RawActivity represents an activity as it is stored in the activitylog store

type Resource

type Resource struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Resource represents an item such as a file or folder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL