Merge branch 'main' of git.mstar.dev:mstar/linstrom

This commit is contained in:
Melody Becker 2025-05-05 17:56:01 +02:00
commit 412a8be600
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
13 changed files with 709 additions and 252 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/rs/zerolog/hlog"
"gorm.io/gorm"
"git.mstar.dev/mstar/linstrom/shared"
"git.mstar.dev/mstar/linstrom/storage-new"
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
"git.mstar.dev/mstar/linstrom/storage-new/models"
@ -64,7 +65,7 @@ func postAs(w http.ResponseWriter, r *http.Request) {
AccessLevel: models.NOTE_TARGET_PUBLIC,
OriginId: 1,
}
n.Select(
err = n.Select(
n.CreatorId,
n.RawContent,
n.Remote,
@ -74,6 +75,26 @@ func postAs(w http.ResponseWriter, r *http.Request) {
n.AccessLevel,
n.OriginId,
).Create(&note)
if err != nil {
log.Error().
Err(err).
Str("username", data.Username).
Str("content", data.Content).
Msg("Failed to create message")
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
return
}
activity := models.Activity{
Id: shared.NewId(),
Type: string(models.ActivityCreate),
ObjectId: note.ID,
ObjectType: uint32(models.ActivitystreamsActivityTargetNote),
}
a := dbgen.Activity
err = a.Create(&activity)
if err != nil {
log.Error().Err(err).Msg("Failed to create activity for new note")
}
}
func notesFrom(w http.ResponseWriter, r *http.Request) {

View file

@ -58,9 +58,9 @@ func activityCreate(w http.ResponseWriter, r *http.Request) {
// getting the final result
func createFromStorage(ctx context.Context, id string) (*activityCreateOut, error) {
// log := log.Ctx(ctx)
asa := dbgen.ActivitystreamsActivity
activity, err := asa.Where(asa.Type.Eq(string(models.ActivityCreate))).
Where(asa.Id.Eq(id)).
a := dbgen.Activity
activity, err := a.Where(a.Type.Eq(string(models.ActivityCreate))).
Where(a.Id.Eq(id)).
First()
if err != nil {
return nil, err