lena

joined 6 months ago
MODERATOR OF
[–] lena@gregtech.eu 2 points 4 hours ago (1 children)

Wow, so pretty!

I basically only play minecraft on a server with some friends. We have a voice chat plugin and it's great.

Otherwise I haven't been playing games a lot, I've been mostly programming :3

I wish I had programmer socks, I'd love to post on !unixsocks@lemmy.blahaj.zone but I don't have any :(

[–] lena@gregtech.eu 6 points 5 hours ago (1 children)

I really like Cockta, used to be owned by a Slovenian company, currently by Croatians. Still european!

[–] lena@gregtech.eu 1 points 7 hours ago (1 children)

I'm not exactly sure what you want here.

  1. If you'd like votes to not be federated at all, that would mean instances would only have the local count of votes (i.e. only votes cast by users from that instance), which brings little benefit, and would make small instances unusable.

  2. If you'd like only vote counts to be federated, but not who cast the votes, that would allow people to make accounts spamming votes, with admins from other instances being unable to figure out where the spurious votes are coming from. As in the previous example, it would bring little benefit (votes would be private, sure), but it would cripple moderation tools and make post and comment ranking untrustworthy because of potential (virtually) undetectable bots.

[–] lena@gregtech.eu 2 points 11 hours ago (1 children)

This is great, DEFCON talks are always amazing :D

The one about email is also great.

[–] lena@gregtech.eu 0 points 14 hours ago (1 children)

Or matrix, which I prefer. XMPP has a myriad of issues, and matrix is more modern with a better ecosystem of clients and servers.

[–] lena@gregtech.eu 2 points 15 hours ago

I already use it in Lemvotes and it's quite funny

[–] lena@gregtech.eu 6 points 1 day ago (1 children)

Jerk, I'd say, though that would be shaking shaking my head, not shaking my head my head

[–] lena@gregtech.eu 22 points 1 day ago (3 children)

I'd shake hands with fascists

[–] lena@gregtech.eu 3 points 1 day ago (3 children)
[–] lena@gregtech.eu 4 points 1 day ago

Their CI/CD minutes are very generous (unlimited!). Plus, if Microsoft wanted to scrape code, it doesn't have to be on Github. They can scrape it off codeberg too. And I can be sure Github won't shut down.

If Github does decide to screw users over, switching to self-hosted forgejo would be trivial.

[–] lena@gregtech.eu 2 points 1 day ago (1 children)

Well it says 27 >:(

[–] lena@gregtech.eu 8 points 1 day ago

Gotta flex those pecs

 

cross-posted from: https://gregtech.eu/post/16825706

API for HTTP Cats

 

API for HTTP Cats

40
Wat (www.destroyallsoftware.com)
 

This is an amazing explanation of inheritance

 

on the voyager Github

I have to open the 197th one 😭

 

cross-posted from: https://gregtech.eu/post/16712875

Marshaling the field is fine, so using the tag json:"-" won't work. I could use the UnmarshalJSON method on the struct, but I have no idea how to implement it.

I'd rather not make a duplicate of the struct with that field removed, as it causes quite a bit of code duplication, and it's pretty chaotic.

 

Marshaling the field is fine, so using the tag json:"-" won't work. I could use the UnmarshalJSON method on the struct, but I have no idea how to implement it.

I'd rather not make a duplicate of the struct with that field removed, as it causes quite a bit of code duplication, and it's pretty chaotic.

 

cross-posted from: https://gregtech.eu/post/16416819

Hi, what's the best way for testing a gin route?

I currently have one function where the routes are defined. Here it is:

package router

import (
	"github.com/gin-gonic/gin"
	"github.com/gragorther/epigo/handlers"
	"github.com/gragorther/epigo/middlewares"
)

func Setup(userUserStore handlers.UserUserStore, groupGroupStore handlers.GroupGroupStore, groupAuthStore handlers.GroupAuthStore, messageAuthStore handlers.MessageAuthStore, messageMessageStore handlers.MessageMessageStore, middlewareUserStore middlewares.UserStore) *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.ErrorHandler())

	userHandler := handlers.NewUserHandler(userUserStore)
	authHandler := middlewares.NewAuthMiddleware(middlewareUserStore)
	groupHandler := handlers.NewGroupHandler(groupGroupStore, groupAuthStore)
	messageHandler := handlers.NewMessageHandler(messageMessageStore, messageAuthStore)

	// user stuff
	r.POST("/user/register", userHandler.RegisterUser)
	r.POST("/user/login", userHandler.LoginUser)
	r.GET("/user/profile", authHandler.CheckAuth, userHandler.GetUserProfile)
	r.PUT("/user/setEmailInterval", authHandler.CheckAuth, userHandler.SetEmailInterval)

	// groups
	r.DELETE("/user/groups/delete/:id", authHandler.CheckAuth, groupHandler.DeleteGroup)
	r.POST("/user/groups/add", authHandler.CheckAuth, groupHandler.AddGroup)
	r.GET("/user/groups", authHandler.CheckAuth, groupHandler.ListGroups) // list groups
	r.PATCH("/user/groups/edit/:id", authHandler.CheckAuth, groupHandler.EditGroup)

	// lastMessages
	r.POST("/user/lastMessages/add", authHandler.CheckAuth, messageHandler.AddLastMessage)
	r.GET("/user/lastMessages", authHandler.CheckAuth, messageHandler.ListLastMessages)
	r.PATCH("/user/lastMessages/edit/:id", authHandler.CheckAuth, messageHandler.EditLastMessage)
	r.DELETE("/user/lastMessages/delete/:id", authHandler.CheckAuth, messageHandler.DeleteLastMessage)
	return r
}

so, my question is, how can I test just one route? should I run this function in every test and send a request to a route with httptest? Or should I set up my handlers like it's described at https://gin-gonic.com/en/docs/testing/

(like this)

func postUser(router *gin.Engine) *gin.Engine {
  router.POST("/user/add", func(c *gin.Context) {
    var user User
    c.BindJSON(&user)
    c.JSON(200, user)
  })
  return router
}

let me know if you have any other questions about my code.

It's available on github: https://github.com/gragorther/epigo

 

cross-posted from: https://gregtech.eu/post/16416819

Hi, what's the best way for testing a gin route?

I currently have one function where the routes are defined. Here it is:

package router

import (
	"github.com/gin-gonic/gin"
	"github.com/gragorther/epigo/handlers"
	"github.com/gragorther/epigo/middlewares"
)

func Setup(userUserStore handlers.UserUserStore, groupGroupStore handlers.GroupGroupStore, groupAuthStore handlers.GroupAuthStore, messageAuthStore handlers.MessageAuthStore, messageMessageStore handlers.MessageMessageStore, middlewareUserStore middlewares.UserStore) *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.ErrorHandler())

	userHandler := handlers.NewUserHandler(userUserStore)
	authHandler := middlewares.NewAuthMiddleware(middlewareUserStore)
	groupHandler := handlers.NewGroupHandler(groupGroupStore, groupAuthStore)
	messageHandler := handlers.NewMessageHandler(messageMessageStore, messageAuthStore)

	// user stuff
	r.POST("/user/register", userHandler.RegisterUser)
	r.POST("/user/login", userHandler.LoginUser)
	r.GET("/user/profile", authHandler.CheckAuth, userHandler.GetUserProfile)
	r.PUT("/user/setEmailInterval", authHandler.CheckAuth, userHandler.SetEmailInterval)

	// groups
	r.DELETE("/user/groups/delete/:id", authHandler.CheckAuth, groupHandler.DeleteGroup)
	r.POST("/user/groups/add", authHandler.CheckAuth, groupHandler.AddGroup)
	r.GET("/user/groups", authHandler.CheckAuth, groupHandler.ListGroups) // list groups
	r.PATCH("/user/groups/edit/:id", authHandler.CheckAuth, groupHandler.EditGroup)

	// lastMessages
	r.POST("/user/lastMessages/add", authHandler.CheckAuth, messageHandler.AddLastMessage)
	r.GET("/user/lastMessages", authHandler.CheckAuth, messageHandler.ListLastMessages)
	r.PATCH("/user/lastMessages/edit/:id", authHandler.CheckAuth, messageHandler.EditLastMessage)
	r.DELETE("/user/lastMessages/delete/:id", authHandler.CheckAuth, messageHandler.DeleteLastMessage)
	return r
}

so, my question is, how can I test just one route? should I run this function in every test and send a request to a route with httptest? Or should I set up my handlers like it's described at https://gin-gonic.com/en/docs/testing/

(like this)

func postUser(router *gin.Engine) *gin.Engine {
  router.POST("/user/add", func(c *gin.Context) {
    var user User
    c.BindJSON(&user)
    c.JSON(200, user)
  })
  return router
}

let me know if you have any other questions about my code.

It's available on github: https://github.com/gragorther/epigo

view more: next ›