Merge branch 'main' of git.mstar.dev:mstar/linstrom
This commit is contained in:
commit
412a8be600
13 changed files with 709 additions and 252 deletions
|
@ -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(¬e)
|
||||
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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue