🗑️ Remove independent mode
This commit is contained in:
		@@ -74,12 +74,10 @@ func getAttachmentMeta(c *fiber.Ctx) error {
 | 
			
		||||
 | 
			
		||||
func createAttachment(c *fiber.Ctx) error {
 | 
			
		||||
	var user *models.Account
 | 
			
		||||
	if gap.H != nil {
 | 
			
		||||
		if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		user = lo.ToPtr(c.Locals("user").(models.Account))
 | 
			
		||||
	if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	user = lo.ToPtr(c.Locals("user").(models.Account))
 | 
			
		||||
 | 
			
		||||
	destName := c.Query("destination", viper.GetString("preferred_destination"))
 | 
			
		||||
 | 
			
		||||
@@ -97,10 +95,8 @@ func createAttachment(c *fiber.Ctx) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if gap.H != nil {
 | 
			
		||||
		if err := gap.H.EnsureGrantedPerm(c, "CreateAttachments", file.Size); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	if err := gap.H.EnsureGrantedPerm(c, "CreateAttachments", file.Size); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	usermeta := make(map[string]any)
 | 
			
		||||
@@ -136,10 +132,6 @@ func createAttachment(c *fiber.Ctx) error {
 | 
			
		||||
func updateAttachmentMeta(c *fiber.Ctx) error {
 | 
			
		||||
	id, _ := c.ParamsInt("id", 0)
 | 
			
		||||
 | 
			
		||||
	if gap.H == nil {
 | 
			
		||||
		return fiber.NewError(fiber.StatusUnprocessableEntity, "server running in independent mode, unable to modify attachment meta")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@@ -176,10 +168,6 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
 | 
			
		||||
func deleteAttachment(c *fiber.Ctx) error {
 | 
			
		||||
	id, _ := c.ParamsInt("id", 0)
 | 
			
		||||
 | 
			
		||||
	if gap.H == nil {
 | 
			
		||||
		return fiber.NewError(fiber.StatusUnprocessableEntity, "server running in independent mode, unable to delete attachment")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -44,12 +44,8 @@ func main() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Connect other services
 | 
			
		||||
	if !viper.GetBool("independent_mode") {
 | 
			
		||||
		if err := gap.RegisterService(); err != nil {
 | 
			
		||||
			log.Error().Err(err).Msg("An error occurred when registering service to dealer...")
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Warn().Msg("WATCHOUT! Running in independent mode, everyone with access to API can upload their file without authenticate!")
 | 
			
		||||
	if err := gap.RegisterService(); err != nil {
 | 
			
		||||
		log.Error().Err(err).Msg("An error occurred when registering service to dealer...")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Configure timed tasks
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,6 @@ grpc_bind = "0.0.0.0:7443"
 | 
			
		||||
domain = "usercontent.solsynth.dev"
 | 
			
		||||
secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
 | 
			
		||||
 | 
			
		||||
independent_mode = false
 | 
			
		||||
 | 
			
		||||
preferred_destination = "local"
 | 
			
		||||
accepts_usage = ["p.avatar", "p.banner", "i.attachment", "m.attachment"]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user