🗑️ Remove independent mode
This commit is contained in:
		@@ -74,12 +74,10 @@ func getAttachmentMeta(c *fiber.Ctx) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func createAttachment(c *fiber.Ctx) error {
 | 
					func createAttachment(c *fiber.Ctx) error {
 | 
				
			||||||
	var user *models.Account
 | 
						var user *models.Account
 | 
				
			||||||
	if gap.H != nil {
 | 
					 | 
				
			||||||
	if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
						if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	user = lo.ToPtr(c.Locals("user").(models.Account))
 | 
						user = lo.ToPtr(c.Locals("user").(models.Account))
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	destName := c.Query("destination", viper.GetString("preferred_destination"))
 | 
						destName := c.Query("destination", viper.GetString("preferred_destination"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -97,11 +95,9 @@ func createAttachment(c *fiber.Ctx) error {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if gap.H != nil {
 | 
					 | 
				
			||||||
	if err := gap.H.EnsureGrantedPerm(c, "CreateAttachments", file.Size); err != nil {
 | 
						if err := gap.H.EnsureGrantedPerm(c, "CreateAttachments", file.Size); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	usermeta := make(map[string]any)
 | 
						usermeta := make(map[string]any)
 | 
				
			||||||
	_ = jsoniter.UnmarshalFromString(c.FormValue("metadata"), &usermeta)
 | 
						_ = jsoniter.UnmarshalFromString(c.FormValue("metadata"), &usermeta)
 | 
				
			||||||
@@ -136,10 +132,6 @@ func createAttachment(c *fiber.Ctx) error {
 | 
				
			|||||||
func updateAttachmentMeta(c *fiber.Ctx) error {
 | 
					func updateAttachmentMeta(c *fiber.Ctx) error {
 | 
				
			||||||
	id, _ := c.ParamsInt("id", 0)
 | 
						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 {
 | 
						if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -176,10 +168,6 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
 | 
				
			|||||||
func deleteAttachment(c *fiber.Ctx) error {
 | 
					func deleteAttachment(c *fiber.Ctx) error {
 | 
				
			||||||
	id, _ := c.ParamsInt("id", 0)
 | 
						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 {
 | 
						if err := gap.H.EnsureAuthenticated(c); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,13 +44,9 @@ func main() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Connect other services
 | 
						// Connect other services
 | 
				
			||||||
	if !viper.GetBool("independent_mode") {
 | 
					 | 
				
			||||||
	if err := gap.RegisterService(); err != nil {
 | 
						if err := gap.RegisterService(); err != nil {
 | 
				
			||||||
		log.Error().Err(err).Msg("An error occurred when registering service to dealer...")
 | 
							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!")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Configure timed tasks
 | 
						// Configure timed tasks
 | 
				
			||||||
	quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
 | 
						quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,8 +5,6 @@ grpc_bind = "0.0.0.0:7443"
 | 
				
			|||||||
domain = "usercontent.solsynth.dev"
 | 
					domain = "usercontent.solsynth.dev"
 | 
				
			||||||
secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
 | 
					secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
independent_mode = false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
preferred_destination = "local"
 | 
					preferred_destination = "local"
 | 
				
			||||||
accepts_usage = ["p.avatar", "p.banner", "i.attachment", "m.attachment"]
 | 
					accepts_usage = ["p.avatar", "p.banner", "i.attachment", "m.attachment"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user