✨ Implement event recorder grpc
This commit is contained in:
parent
06bd632f37
commit
a4a139c56e
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@ -4,10 +4,10 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes on multi-factors based authentication">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes on settings auth preferences">
|
||||||
|
<change afterPath="$PROJECT_DIR$/pkg/internal/grpc/events.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/models/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/auth.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/server.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/preferences_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/preferences_api.go" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -154,7 +154,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":bug: Fix compare perm node function" />
|
|
||||||
<MESSAGE value=":sparkles: Bot related bot key apis" />
|
<MESSAGE value=":sparkles: Bot related bot key apis" />
|
||||||
<MESSAGE value=":bug: Fix bot related bot key apis path error" />
|
<MESSAGE value=":bug: Fix bot related bot key apis path error" />
|
||||||
<MESSAGE value=":bug: Fix path parameters misplaced" />
|
<MESSAGE value=":bug: Fix path parameters misplaced" />
|
||||||
@ -179,7 +178,8 @@
|
|||||||
<MESSAGE value=":sparkles: Allow user view and remove notification subscriptions" />
|
<MESSAGE value=":sparkles: Allow user view and remove notification subscriptions" />
|
||||||
<MESSAGE value=":recycle: Improve notifications mark read system" />
|
<MESSAGE value=":recycle: Improve notifications mark read system" />
|
||||||
<MESSAGE value=":bug: Bug fixes on multi-factors based authentication" />
|
<MESSAGE value=":bug: Bug fixes on multi-factors based authentication" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes on multi-factors based authentication" />
|
<MESSAGE value=":bug: Bug fixes on settings auth preferences" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes on settings auth preferences" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
20
pkg/internal/grpc/events.go
Normal file
20
pkg/internal/grpc/events.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v *Server) RecordEvent(ctx context.Context, request *proto.RecordEventRequest) (*proto.RecordEventResponse, error) {
|
||||||
|
var user models.Account
|
||||||
|
var err error
|
||||||
|
if user, err = services.GetAccount(uint(request.GetUserId())); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
services.AddEvent(user, request.GetAction(), request.GetTarget(), request.GetIp(), request.GetUserAgent())
|
||||||
|
|
||||||
|
return &proto.RecordEventResponse{IsSuccess: true}, nil
|
||||||
|
}
|
@ -17,6 +17,7 @@ type Server struct {
|
|||||||
proto.UnimplementedNotifierServer
|
proto.UnimplementedNotifierServer
|
||||||
proto.UnimplementedRealmServer
|
proto.UnimplementedRealmServer
|
||||||
proto.UnimplementedStreamControllerServer
|
proto.UnimplementedStreamControllerServer
|
||||||
|
proto.UnimplementedEventRecorderServer
|
||||||
health.UnimplementedHealthServer
|
health.UnimplementedHealthServer
|
||||||
|
|
||||||
srv *grpc.Server
|
srv *grpc.Server
|
||||||
@ -31,6 +32,7 @@ func NewServer() *Server {
|
|||||||
proto.RegisterNotifierServer(server.srv, server)
|
proto.RegisterNotifierServer(server.srv, server)
|
||||||
proto.RegisterRealmServer(server.srv, server)
|
proto.RegisterRealmServer(server.srv, server)
|
||||||
proto.RegisterStreamControllerServer(server.srv, server)
|
proto.RegisterStreamControllerServer(server.srv, server)
|
||||||
|
proto.RegisterEventRecorderServer(server.srv, server)
|
||||||
health.RegisterHealthServer(server.srv, server)
|
health.RegisterHealthServer(server.srv, server)
|
||||||
|
|
||||||
reflection.Register(server.srv)
|
reflection.Register(server.srv)
|
||||||
|
Loading…
Reference in New Issue
Block a user