Use ID types
This commit is contained in:
@@ -24,18 +24,16 @@ import (
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
Config scn.Config
|
||||
Gin *gin.Engine
|
||||
Database *db.Database
|
||||
Firebase *firebase.FBConnector
|
||||
DefaultChannel string
|
||||
Jobs []Job
|
||||
Config scn.Config
|
||||
Gin *gin.Engine
|
||||
Database *db.Database
|
||||
Firebase *firebase.FBConnector
|
||||
Jobs []Job
|
||||
}
|
||||
|
||||
func NewApp(db *db.Database) *Application {
|
||||
return &Application{
|
||||
Database: db,
|
||||
DefaultChannel: "main",
|
||||
Database: db,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +192,7 @@ func (app *Application) getPermissions(ctx *AppContext, hdr string) (PermissionS
|
||||
return NewEmptyPermissions(), nil
|
||||
}
|
||||
|
||||
func (app *Application) GetOrCreateChannel(ctx *AppContext, userid int64, chanName string) (models.Channel, error) {
|
||||
func (app *Application) GetOrCreateChannel(ctx *AppContext, userid models.UserID, chanName string) (models.Channel, error) {
|
||||
chanName = app.NormalizeChannelName(chanName)
|
||||
|
||||
existingChan, err := app.Database.GetChannelByName(ctx, userid, chanName)
|
||||
@@ -245,7 +243,7 @@ func (app *Application) DeliverMessage(ctx context.Context, client models.Client
|
||||
if client.FCMToken != nil {
|
||||
fcmDelivID, err := app.Firebase.SendNotification(ctx, client, msg)
|
||||
if err != nil {
|
||||
log.Warn().Int64("SCNMessageID", msg.SCNMessageID).Int64("ClientID", client.ClientID).Err(err).Msg("FCM Delivery failed")
|
||||
log.Warn().Int64("SCNMessageID", msg.SCNMessageID.IntID()).Int64("ClientID", client.ClientID.IntID()).Err(err).Msg("FCM Delivery failed")
|
||||
return nil, err
|
||||
}
|
||||
return langext.Ptr(fcmDelivID), nil
|
||||
|
@@ -17,7 +17,7 @@ const (
|
||||
)
|
||||
|
||||
type PermissionSet struct {
|
||||
UserID *int64
|
||||
UserID *models.UserID
|
||||
KeyType PermKeyType
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func NewEmptyPermissions() PermissionSet {
|
||||
}
|
||||
}
|
||||
|
||||
func (ac *AppContext) CheckPermissionUserRead(userid int64) *ginresp.HTTPResponse {
|
||||
func (ac *AppContext) CheckPermissionUserRead(userid models.UserID) *ginresp.HTTPResponse {
|
||||
p := ac.permissions
|
||||
if p.UserID != nil && *p.UserID == userid && p.KeyType == PermKeyTypeUserRead {
|
||||
return nil
|
||||
@@ -52,7 +52,7 @@ func (ac *AppContext) CheckPermissionRead() *ginresp.HTTPResponse {
|
||||
return langext.Ptr(ginresp.APIError(ac.ginContext, 401, apierr.USER_AUTH_FAILED, "You are not authorized for this action", nil))
|
||||
}
|
||||
|
||||
func (ac *AppContext) CheckPermissionUserAdmin(userid int64) *ginresp.HTTPResponse {
|
||||
func (ac *AppContext) CheckPermissionUserAdmin(userid models.UserID) *ginresp.HTTPResponse {
|
||||
p := ac.permissions
|
||||
if p.UserID != nil && *p.UserID == userid && p.KeyType == PermKeyTypeUserAdmin {
|
||||
return nil
|
||||
@@ -94,7 +94,7 @@ func (ac *AppContext) CheckPermissionMessageReadDirect(msg models.Message) bool
|
||||
return false
|
||||
}
|
||||
|
||||
func (ac *AppContext) GetPermissionUserID() *int64 {
|
||||
func (ac *AppContext) GetPermissionUserID() *models.UserID {
|
||||
if ac.permissions.UserID == nil {
|
||||
return nil
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user