More activity stuff
Some checks failed
/ docker (push) Failing after 2m51s

This commit is contained in:
Melody Becker 2025-05-05 17:33:34 +02:00
parent 12c9e17c4b
commit dff031397e
14 changed files with 710 additions and 253 deletions

View file

@ -0,0 +1,394 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package dbgen
import (
"context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
)
func newActivity(db *gorm.DB, opts ...gen.DOOption) activity {
_activity := activity{}
_activity.activityDo.UseDB(db, opts...)
_activity.activityDo.UseModel(&models.Activity{})
tableName := _activity.activityDo.TableName()
_activity.ALL = field.NewAsterisk(tableName)
_activity.Id = field.NewString(tableName, "id")
_activity.Type = field.NewString(tableName, "type")
_activity.ObjectId = field.NewString(tableName, "object_id")
_activity.ObjectType = field.NewUint32(tableName, "object_type")
_activity.fillFieldMap()
return _activity
}
type activity struct {
activityDo
ALL field.Asterisk
Id field.String
Type field.String
ObjectId field.String
ObjectType field.Uint32
fieldMap map[string]field.Expr
}
func (a activity) Table(newTableName string) *activity {
a.activityDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a activity) As(alias string) *activity {
a.activityDo.DO = *(a.activityDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *activity) updateTableName(table string) *activity {
a.ALL = field.NewAsterisk(table)
a.Id = field.NewString(table, "id")
a.Type = field.NewString(table, "type")
a.ObjectId = field.NewString(table, "object_id")
a.ObjectType = field.NewUint32(table, "object_type")
a.fillFieldMap()
return a
}
func (a *activity) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *activity) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 4)
a.fieldMap["id"] = a.Id
a.fieldMap["type"] = a.Type
a.fieldMap["object_id"] = a.ObjectId
a.fieldMap["object_type"] = a.ObjectType
}
func (a activity) clone(db *gorm.DB) activity {
a.activityDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a activity) replaceDB(db *gorm.DB) activity {
a.activityDo.ReplaceDB(db)
return a
}
type activityDo struct{ gen.DO }
type IActivityDo interface {
gen.SubQuery
Debug() IActivityDo
WithContext(ctx context.Context) IActivityDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IActivityDo
WriteDB() IActivityDo
As(alias string) gen.Dao
Session(config *gorm.Session) IActivityDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IActivityDo
Not(conds ...gen.Condition) IActivityDo
Or(conds ...gen.Condition) IActivityDo
Select(conds ...field.Expr) IActivityDo
Where(conds ...gen.Condition) IActivityDo
Order(conds ...field.Expr) IActivityDo
Distinct(cols ...field.Expr) IActivityDo
Omit(cols ...field.Expr) IActivityDo
Join(table schema.Tabler, on ...field.Expr) IActivityDo
LeftJoin(table schema.Tabler, on ...field.Expr) IActivityDo
RightJoin(table schema.Tabler, on ...field.Expr) IActivityDo
Group(cols ...field.Expr) IActivityDo
Having(conds ...gen.Condition) IActivityDo
Limit(limit int) IActivityDo
Offset(offset int) IActivityDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IActivityDo
Unscoped() IActivityDo
Create(values ...*models.Activity) error
CreateInBatches(values []*models.Activity, batchSize int) error
Save(values ...*models.Activity) error
First() (*models.Activity, error)
Take() (*models.Activity, error)
Last() (*models.Activity, error)
Find() ([]*models.Activity, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error)
FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*models.Activity) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IActivityDo
Assign(attrs ...field.AssignExpr) IActivityDo
Joins(fields ...field.RelationField) IActivityDo
Preload(fields ...field.RelationField) IActivityDo
FirstOrInit() (*models.Activity, error)
FirstOrCreate() (*models.Activity, error)
FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Rows() (*sql.Rows, error)
Row() *sql.Row
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IActivityDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a activityDo) Debug() IActivityDo {
return a.withDO(a.DO.Debug())
}
func (a activityDo) WithContext(ctx context.Context) IActivityDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a activityDo) ReadDB() IActivityDo {
return a.Clauses(dbresolver.Read)
}
func (a activityDo) WriteDB() IActivityDo {
return a.Clauses(dbresolver.Write)
}
func (a activityDo) Session(config *gorm.Session) IActivityDo {
return a.withDO(a.DO.Session(config))
}
func (a activityDo) Clauses(conds ...clause.Expression) IActivityDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a activityDo) Returning(value interface{}, columns ...string) IActivityDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a activityDo) Not(conds ...gen.Condition) IActivityDo {
return a.withDO(a.DO.Not(conds...))
}
func (a activityDo) Or(conds ...gen.Condition) IActivityDo {
return a.withDO(a.DO.Or(conds...))
}
func (a activityDo) Select(conds ...field.Expr) IActivityDo {
return a.withDO(a.DO.Select(conds...))
}
func (a activityDo) Where(conds ...gen.Condition) IActivityDo {
return a.withDO(a.DO.Where(conds...))
}
func (a activityDo) Order(conds ...field.Expr) IActivityDo {
return a.withDO(a.DO.Order(conds...))
}
func (a activityDo) Distinct(cols ...field.Expr) IActivityDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a activityDo) Omit(cols ...field.Expr) IActivityDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a activityDo) Join(table schema.Tabler, on ...field.Expr) IActivityDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a activityDo) LeftJoin(table schema.Tabler, on ...field.Expr) IActivityDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a activityDo) RightJoin(table schema.Tabler, on ...field.Expr) IActivityDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a activityDo) Group(cols ...field.Expr) IActivityDo {
return a.withDO(a.DO.Group(cols...))
}
func (a activityDo) Having(conds ...gen.Condition) IActivityDo {
return a.withDO(a.DO.Having(conds...))
}
func (a activityDo) Limit(limit int) IActivityDo {
return a.withDO(a.DO.Limit(limit))
}
func (a activityDo) Offset(offset int) IActivityDo {
return a.withDO(a.DO.Offset(offset))
}
func (a activityDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IActivityDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a activityDo) Unscoped() IActivityDo {
return a.withDO(a.DO.Unscoped())
}
func (a activityDo) Create(values ...*models.Activity) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a activityDo) CreateInBatches(values []*models.Activity, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a activityDo) Save(values ...*models.Activity) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a activityDo) First() (*models.Activity, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*models.Activity), nil
}
}
func (a activityDo) Take() (*models.Activity, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*models.Activity), nil
}
}
func (a activityDo) Last() (*models.Activity, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*models.Activity), nil
}
}
func (a activityDo) Find() ([]*models.Activity, error) {
result, err := a.DO.Find()
return result.([]*models.Activity), err
}
func (a activityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error) {
buf := make([]*models.Activity, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a activityDo) FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a activityDo) Attrs(attrs ...field.AssignExpr) IActivityDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a activityDo) Assign(attrs ...field.AssignExpr) IActivityDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a activityDo) Joins(fields ...field.RelationField) IActivityDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a activityDo) Preload(fields ...field.RelationField) IActivityDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a activityDo) FirstOrInit() (*models.Activity, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*models.Activity), nil
}
}
func (a activityDo) FirstOrCreate() (*models.Activity, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*models.Activity), nil
}
}
func (a activityDo) FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a activityDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a activityDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a activityDo) Delete(models ...*models.Activity) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *activityDo) withDO(do gen.Dao) *activityDo {
a.DO = *do.(*gen.DO)
return a
}

View file

@ -23,7 +23,7 @@ func newActivitystreamsActivity(db *gorm.DB, opts ...gen.DOOption) activitystrea
_activitystreamsActivity := activitystreamsActivity{} _activitystreamsActivity := activitystreamsActivity{}
_activitystreamsActivity.activitystreamsActivityDo.UseDB(db, opts...) _activitystreamsActivity.activitystreamsActivityDo.UseDB(db, opts...)
_activitystreamsActivity.activitystreamsActivityDo.UseModel(&models.ActivitystreamsActivity{}) _activitystreamsActivity.activitystreamsActivityDo.UseModel(&models.Activity{})
tableName := _activitystreamsActivity.activitystreamsActivityDo.TableName() tableName := _activitystreamsActivity.activitystreamsActivityDo.TableName()
_activitystreamsActivity.ALL = field.NewAsterisk(tableName) _activitystreamsActivity.ALL = field.NewAsterisk(tableName)
@ -129,17 +129,17 @@ type IActivitystreamsActivityDo interface {
Count() (count int64, err error) Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IActivitystreamsActivityDo Scopes(funcs ...func(gen.Dao) gen.Dao) IActivitystreamsActivityDo
Unscoped() IActivitystreamsActivityDo Unscoped() IActivitystreamsActivityDo
Create(values ...*models.ActivitystreamsActivity) error Create(values ...*models.Activity) error
CreateInBatches(values []*models.ActivitystreamsActivity, batchSize int) error CreateInBatches(values []*models.Activity, batchSize int) error
Save(values ...*models.ActivitystreamsActivity) error Save(values ...*models.Activity) error
First() (*models.ActivitystreamsActivity, error) First() (*models.Activity, error)
Take() (*models.ActivitystreamsActivity, error) Take() (*models.Activity, error)
Last() (*models.ActivitystreamsActivity, error) Last() (*models.Activity, error)
Find() ([]*models.ActivitystreamsActivity, error) Find() ([]*models.Activity, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ActivitystreamsActivity, err error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error)
FindInBatches(result *[]*models.ActivitystreamsActivity, batchSize int, fc func(tx gen.Dao, batch int) error) error FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error Pluck(column field.Expr, dest interface{}) error
Delete(...*models.ActivitystreamsActivity) (info gen.ResultInfo, err error) Delete(...*models.Activity) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error) Updates(value interface{}) (info gen.ResultInfo, err error)
@ -151,9 +151,9 @@ type IActivitystreamsActivityDo interface {
Assign(attrs ...field.AssignExpr) IActivitystreamsActivityDo Assign(attrs ...field.AssignExpr) IActivitystreamsActivityDo
Joins(fields ...field.RelationField) IActivitystreamsActivityDo Joins(fields ...field.RelationField) IActivitystreamsActivityDo
Preload(fields ...field.RelationField) IActivitystreamsActivityDo Preload(fields ...field.RelationField) IActivitystreamsActivityDo
FirstOrInit() (*models.ActivitystreamsActivity, error) FirstOrInit() (*models.Activity, error)
FirstOrCreate() (*models.ActivitystreamsActivity, error) FirstOrCreate() (*models.Activity, error)
FindByPage(offset int, limit int) (result []*models.ActivitystreamsActivity, count int64, err error) FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error) ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Rows() (*sql.Rows, error) Rows() (*sql.Rows, error)
Row() *sql.Row Row() *sql.Row
@ -255,57 +255,57 @@ func (a activitystreamsActivityDo) Unscoped() IActivitystreamsActivityDo {
return a.withDO(a.DO.Unscoped()) return a.withDO(a.DO.Unscoped())
} }
func (a activitystreamsActivityDo) Create(values ...*models.ActivitystreamsActivity) error { func (a activitystreamsActivityDo) Create(values ...*models.Activity) error {
if len(values) == 0 { if len(values) == 0 {
return nil return nil
} }
return a.DO.Create(values) return a.DO.Create(values)
} }
func (a activitystreamsActivityDo) CreateInBatches(values []*models.ActivitystreamsActivity, batchSize int) error { func (a activitystreamsActivityDo) CreateInBatches(values []*models.Activity, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize) return a.DO.CreateInBatches(values, batchSize)
} }
// Save : !!! underlying implementation is different with GORM // Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a activitystreamsActivityDo) Save(values ...*models.ActivitystreamsActivity) error { func (a activitystreamsActivityDo) Save(values ...*models.Activity) error {
if len(values) == 0 { if len(values) == 0 {
return nil return nil
} }
return a.DO.Save(values) return a.DO.Save(values)
} }
func (a activitystreamsActivityDo) First() (*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) First() (*models.Activity, error) {
if result, err := a.DO.First(); err != nil { if result, err := a.DO.First(); err != nil {
return nil, err return nil, err
} else { } else {
return result.(*models.ActivitystreamsActivity), nil return result.(*models.Activity), nil
} }
} }
func (a activitystreamsActivityDo) Take() (*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) Take() (*models.Activity, error) {
if result, err := a.DO.Take(); err != nil { if result, err := a.DO.Take(); err != nil {
return nil, err return nil, err
} else { } else {
return result.(*models.ActivitystreamsActivity), nil return result.(*models.Activity), nil
} }
} }
func (a activitystreamsActivityDo) Last() (*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) Last() (*models.Activity, error) {
if result, err := a.DO.Last(); err != nil { if result, err := a.DO.Last(); err != nil {
return nil, err return nil, err
} else { } else {
return result.(*models.ActivitystreamsActivity), nil return result.(*models.Activity), nil
} }
} }
func (a activitystreamsActivityDo) Find() ([]*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) Find() ([]*models.Activity, error) {
result, err := a.DO.Find() result, err := a.DO.Find()
return result.([]*models.ActivitystreamsActivity), err return result.([]*models.Activity), err
} }
func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ActivitystreamsActivity, err error) { func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error) {
buf := make([]*models.ActivitystreamsActivity, 0, batchSize) buf := make([]*models.Activity, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }() defer func() { results = append(results, buf...) }()
return fc(tx, batch) return fc(tx, batch)
@ -313,7 +313,7 @@ func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao
return results, err return results, err
} }
func (a activitystreamsActivityDo) FindInBatches(result *[]*models.ActivitystreamsActivity, batchSize int, fc func(tx gen.Dao, batch int) error) error { func (a activitystreamsActivityDo) FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc) return a.DO.FindInBatches(result, batchSize, fc)
} }
@ -339,23 +339,23 @@ func (a activitystreamsActivityDo) Preload(fields ...field.RelationField) IActiv
return &a return &a
} }
func (a activitystreamsActivityDo) FirstOrInit() (*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) FirstOrInit() (*models.Activity, error) {
if result, err := a.DO.FirstOrInit(); err != nil { if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err return nil, err
} else { } else {
return result.(*models.ActivitystreamsActivity), nil return result.(*models.Activity), nil
} }
} }
func (a activitystreamsActivityDo) FirstOrCreate() (*models.ActivitystreamsActivity, error) { func (a activitystreamsActivityDo) FirstOrCreate() (*models.Activity, error) {
if result, err := a.DO.FirstOrCreate(); err != nil { if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err return nil, err
} else { } else {
return result.(*models.ActivitystreamsActivity), nil return result.(*models.Activity), nil
} }
} }
func (a activitystreamsActivityDo) FindByPage(offset int, limit int) (result []*models.ActivitystreamsActivity, count int64, err error) { func (a activitystreamsActivityDo) FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find() result, err = a.Offset(offset).Limit(limit).Find()
if err != nil { if err != nil {
return return
@ -384,7 +384,7 @@ func (a activitystreamsActivityDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result) return a.DO.Scan(result)
} }
func (a activitystreamsActivityDo) Delete(models ...*models.ActivitystreamsActivity) (result gen.ResultInfo, err error) { func (a activitystreamsActivityDo) Delete(models ...*models.Activity) (result gen.ResultInfo, err error) {
return a.DO.Delete(models) return a.DO.Delete(models)
} }

View file

@ -29,7 +29,7 @@ func newCollection(db *gorm.DB, opts ...gen.DOOption) collection {
_collection.ALL = field.NewAsterisk(tableName) _collection.ALL = field.NewAsterisk(tableName)
_collection.Id = field.NewString(tableName, "id") _collection.Id = field.NewString(tableName, "id")
_collection.TargetId = field.NewString(tableName, "target_id") _collection.TargetId = field.NewString(tableName, "target_id")
_collection.TargetType = field.NewUint32(tableName, "target_type") _collection.TargetType = field.NewString(tableName, "target_type")
_collection.fillFieldMap() _collection.fillFieldMap()
@ -42,7 +42,7 @@ type collection struct {
ALL field.Asterisk ALL field.Asterisk
Id field.String Id field.String
TargetId field.String TargetId field.String
TargetType field.Uint32 TargetType field.String
fieldMap map[string]field.Expr fieldMap map[string]field.Expr
} }
@ -61,7 +61,7 @@ func (c *collection) updateTableName(table string) *collection {
c.ALL = field.NewAsterisk(table) c.ALL = field.NewAsterisk(table)
c.Id = field.NewString(table, "id") c.Id = field.NewString(table, "id")
c.TargetId = field.NewString(table, "target_id") c.TargetId = field.NewString(table, "target_id")
c.TargetType = field.NewUint32(table, "target_type") c.TargetType = field.NewString(table, "target_type")
c.fillFieldMap() c.fillFieldMap()

View file

@ -16,42 +16,42 @@ import (
) )
var ( var (
Q = new(Query) Q = new(Query)
AccessToken *accessToken AccessToken *accessToken
ActivitystreamsActivity *activitystreamsActivity Activity *activity
Collection *collection Collection *collection
Emote *emote Emote *emote
Feed *feed Feed *feed
LoginProcessToken *loginProcessToken LoginProcessToken *loginProcessToken
MediaMetadata *mediaMetadata MediaMetadata *mediaMetadata
Note *note Note *note
NoteEdit *noteEdit NoteEdit *noteEdit
NoteTag *noteTag NoteTag *noteTag
NoteToAttachment *noteToAttachment NoteToAttachment *noteToAttachment
NoteToBoost *noteToBoost NoteToBoost *noteToBoost
NoteToEmote *noteToEmote NoteToEmote *noteToEmote
NoteToFeed *noteToFeed NoteToFeed *noteToFeed
NoteToPing *noteToPing NoteToPing *noteToPing
Notification *notification Notification *notification
Reaction *reaction Reaction *reaction
RemoteServer *remoteServer RemoteServer *remoteServer
RemoteServerMetadata *remoteServerMetadata RemoteServerMetadata *remoteServerMetadata
Role *role Role *role
User *user User *user
UserAuthMethod *userAuthMethod UserAuthMethod *userAuthMethod
UserInfoField *userInfoField UserInfoField *userInfoField
UserRemoteLinks *userRemoteLinks UserRemoteLinks *userRemoteLinks
UserToBeing *userToBeing UserToBeing *userToBeing
UserToPronoun *userToPronoun UserToPronoun *userToPronoun
UserToRole *userToRole UserToRole *userToRole
UserToTag *userToTag UserToTag *userToTag
UserToUserRelation *userToUserRelation UserToUserRelation *userToUserRelation
) )
func SetDefault(db *gorm.DB, opts ...gen.DOOption) { func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...) *Q = *Use(db, opts...)
AccessToken = &Q.AccessToken AccessToken = &Q.AccessToken
ActivitystreamsActivity = &Q.ActivitystreamsActivity Activity = &Q.Activity
Collection = &Q.Collection Collection = &Q.Collection
Emote = &Q.Emote Emote = &Q.Emote
Feed = &Q.Feed Feed = &Q.Feed
@ -83,107 +83,107 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
func Use(db *gorm.DB, opts ...gen.DOOption) *Query { func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{ return &Query{
db: db, db: db,
AccessToken: newAccessToken(db, opts...), AccessToken: newAccessToken(db, opts...),
ActivitystreamsActivity: newActivitystreamsActivity(db, opts...), Activity: newActivity(db, opts...),
Collection: newCollection(db, opts...), Collection: newCollection(db, opts...),
Emote: newEmote(db, opts...), Emote: newEmote(db, opts...),
Feed: newFeed(db, opts...), Feed: newFeed(db, opts...),
LoginProcessToken: newLoginProcessToken(db, opts...), LoginProcessToken: newLoginProcessToken(db, opts...),
MediaMetadata: newMediaMetadata(db, opts...), MediaMetadata: newMediaMetadata(db, opts...),
Note: newNote(db, opts...), Note: newNote(db, opts...),
NoteEdit: newNoteEdit(db, opts...), NoteEdit: newNoteEdit(db, opts...),
NoteTag: newNoteTag(db, opts...), NoteTag: newNoteTag(db, opts...),
NoteToAttachment: newNoteToAttachment(db, opts...), NoteToAttachment: newNoteToAttachment(db, opts...),
NoteToBoost: newNoteToBoost(db, opts...), NoteToBoost: newNoteToBoost(db, opts...),
NoteToEmote: newNoteToEmote(db, opts...), NoteToEmote: newNoteToEmote(db, opts...),
NoteToFeed: newNoteToFeed(db, opts...), NoteToFeed: newNoteToFeed(db, opts...),
NoteToPing: newNoteToPing(db, opts...), NoteToPing: newNoteToPing(db, opts...),
Notification: newNotification(db, opts...), Notification: newNotification(db, opts...),
Reaction: newReaction(db, opts...), Reaction: newReaction(db, opts...),
RemoteServer: newRemoteServer(db, opts...), RemoteServer: newRemoteServer(db, opts...),
RemoteServerMetadata: newRemoteServerMetadata(db, opts...), RemoteServerMetadata: newRemoteServerMetadata(db, opts...),
Role: newRole(db, opts...), Role: newRole(db, opts...),
User: newUser(db, opts...), User: newUser(db, opts...),
UserAuthMethod: newUserAuthMethod(db, opts...), UserAuthMethod: newUserAuthMethod(db, opts...),
UserInfoField: newUserInfoField(db, opts...), UserInfoField: newUserInfoField(db, opts...),
UserRemoteLinks: newUserRemoteLinks(db, opts...), UserRemoteLinks: newUserRemoteLinks(db, opts...),
UserToBeing: newUserToBeing(db, opts...), UserToBeing: newUserToBeing(db, opts...),
UserToPronoun: newUserToPronoun(db, opts...), UserToPronoun: newUserToPronoun(db, opts...),
UserToRole: newUserToRole(db, opts...), UserToRole: newUserToRole(db, opts...),
UserToTag: newUserToTag(db, opts...), UserToTag: newUserToTag(db, opts...),
UserToUserRelation: newUserToUserRelation(db, opts...), UserToUserRelation: newUserToUserRelation(db, opts...),
} }
} }
type Query struct { type Query struct {
db *gorm.DB db *gorm.DB
AccessToken accessToken AccessToken accessToken
ActivitystreamsActivity activitystreamsActivity Activity activity
Collection collection Collection collection
Emote emote Emote emote
Feed feed Feed feed
LoginProcessToken loginProcessToken LoginProcessToken loginProcessToken
MediaMetadata mediaMetadata MediaMetadata mediaMetadata
Note note Note note
NoteEdit noteEdit NoteEdit noteEdit
NoteTag noteTag NoteTag noteTag
NoteToAttachment noteToAttachment NoteToAttachment noteToAttachment
NoteToBoost noteToBoost NoteToBoost noteToBoost
NoteToEmote noteToEmote NoteToEmote noteToEmote
NoteToFeed noteToFeed NoteToFeed noteToFeed
NoteToPing noteToPing NoteToPing noteToPing
Notification notification Notification notification
Reaction reaction Reaction reaction
RemoteServer remoteServer RemoteServer remoteServer
RemoteServerMetadata remoteServerMetadata RemoteServerMetadata remoteServerMetadata
Role role Role role
User user User user
UserAuthMethod userAuthMethod UserAuthMethod userAuthMethod
UserInfoField userInfoField UserInfoField userInfoField
UserRemoteLinks userRemoteLinks UserRemoteLinks userRemoteLinks
UserToBeing userToBeing UserToBeing userToBeing
UserToPronoun userToPronoun UserToPronoun userToPronoun
UserToRole userToRole UserToRole userToRole
UserToTag userToTag UserToTag userToTag
UserToUserRelation userToUserRelation UserToUserRelation userToUserRelation
} }
func (q *Query) Available() bool { return q.db != nil } func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query { func (q *Query) clone(db *gorm.DB) *Query {
return &Query{ return &Query{
db: db, db: db,
AccessToken: q.AccessToken.clone(db), AccessToken: q.AccessToken.clone(db),
ActivitystreamsActivity: q.ActivitystreamsActivity.clone(db), Activity: q.Activity.clone(db),
Collection: q.Collection.clone(db), Collection: q.Collection.clone(db),
Emote: q.Emote.clone(db), Emote: q.Emote.clone(db),
Feed: q.Feed.clone(db), Feed: q.Feed.clone(db),
LoginProcessToken: q.LoginProcessToken.clone(db), LoginProcessToken: q.LoginProcessToken.clone(db),
MediaMetadata: q.MediaMetadata.clone(db), MediaMetadata: q.MediaMetadata.clone(db),
Note: q.Note.clone(db), Note: q.Note.clone(db),
NoteEdit: q.NoteEdit.clone(db), NoteEdit: q.NoteEdit.clone(db),
NoteTag: q.NoteTag.clone(db), NoteTag: q.NoteTag.clone(db),
NoteToAttachment: q.NoteToAttachment.clone(db), NoteToAttachment: q.NoteToAttachment.clone(db),
NoteToBoost: q.NoteToBoost.clone(db), NoteToBoost: q.NoteToBoost.clone(db),
NoteToEmote: q.NoteToEmote.clone(db), NoteToEmote: q.NoteToEmote.clone(db),
NoteToFeed: q.NoteToFeed.clone(db), NoteToFeed: q.NoteToFeed.clone(db),
NoteToPing: q.NoteToPing.clone(db), NoteToPing: q.NoteToPing.clone(db),
Notification: q.Notification.clone(db), Notification: q.Notification.clone(db),
Reaction: q.Reaction.clone(db), Reaction: q.Reaction.clone(db),
RemoteServer: q.RemoteServer.clone(db), RemoteServer: q.RemoteServer.clone(db),
RemoteServerMetadata: q.RemoteServerMetadata.clone(db), RemoteServerMetadata: q.RemoteServerMetadata.clone(db),
Role: q.Role.clone(db), Role: q.Role.clone(db),
User: q.User.clone(db), User: q.User.clone(db),
UserAuthMethod: q.UserAuthMethod.clone(db), UserAuthMethod: q.UserAuthMethod.clone(db),
UserInfoField: q.UserInfoField.clone(db), UserInfoField: q.UserInfoField.clone(db),
UserRemoteLinks: q.UserRemoteLinks.clone(db), UserRemoteLinks: q.UserRemoteLinks.clone(db),
UserToBeing: q.UserToBeing.clone(db), UserToBeing: q.UserToBeing.clone(db),
UserToPronoun: q.UserToPronoun.clone(db), UserToPronoun: q.UserToPronoun.clone(db),
UserToRole: q.UserToRole.clone(db), UserToRole: q.UserToRole.clone(db),
UserToTag: q.UserToTag.clone(db), UserToTag: q.UserToTag.clone(db),
UserToUserRelation: q.UserToUserRelation.clone(db), UserToUserRelation: q.UserToUserRelation.clone(db),
} }
} }
@ -197,102 +197,102 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query { func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{ return &Query{
db: db, db: db,
AccessToken: q.AccessToken.replaceDB(db), AccessToken: q.AccessToken.replaceDB(db),
ActivitystreamsActivity: q.ActivitystreamsActivity.replaceDB(db), Activity: q.Activity.replaceDB(db),
Collection: q.Collection.replaceDB(db), Collection: q.Collection.replaceDB(db),
Emote: q.Emote.replaceDB(db), Emote: q.Emote.replaceDB(db),
Feed: q.Feed.replaceDB(db), Feed: q.Feed.replaceDB(db),
LoginProcessToken: q.LoginProcessToken.replaceDB(db), LoginProcessToken: q.LoginProcessToken.replaceDB(db),
MediaMetadata: q.MediaMetadata.replaceDB(db), MediaMetadata: q.MediaMetadata.replaceDB(db),
Note: q.Note.replaceDB(db), Note: q.Note.replaceDB(db),
NoteEdit: q.NoteEdit.replaceDB(db), NoteEdit: q.NoteEdit.replaceDB(db),
NoteTag: q.NoteTag.replaceDB(db), NoteTag: q.NoteTag.replaceDB(db),
NoteToAttachment: q.NoteToAttachment.replaceDB(db), NoteToAttachment: q.NoteToAttachment.replaceDB(db),
NoteToBoost: q.NoteToBoost.replaceDB(db), NoteToBoost: q.NoteToBoost.replaceDB(db),
NoteToEmote: q.NoteToEmote.replaceDB(db), NoteToEmote: q.NoteToEmote.replaceDB(db),
NoteToFeed: q.NoteToFeed.replaceDB(db), NoteToFeed: q.NoteToFeed.replaceDB(db),
NoteToPing: q.NoteToPing.replaceDB(db), NoteToPing: q.NoteToPing.replaceDB(db),
Notification: q.Notification.replaceDB(db), Notification: q.Notification.replaceDB(db),
Reaction: q.Reaction.replaceDB(db), Reaction: q.Reaction.replaceDB(db),
RemoteServer: q.RemoteServer.replaceDB(db), RemoteServer: q.RemoteServer.replaceDB(db),
RemoteServerMetadata: q.RemoteServerMetadata.replaceDB(db), RemoteServerMetadata: q.RemoteServerMetadata.replaceDB(db),
Role: q.Role.replaceDB(db), Role: q.Role.replaceDB(db),
User: q.User.replaceDB(db), User: q.User.replaceDB(db),
UserAuthMethod: q.UserAuthMethod.replaceDB(db), UserAuthMethod: q.UserAuthMethod.replaceDB(db),
UserInfoField: q.UserInfoField.replaceDB(db), UserInfoField: q.UserInfoField.replaceDB(db),
UserRemoteLinks: q.UserRemoteLinks.replaceDB(db), UserRemoteLinks: q.UserRemoteLinks.replaceDB(db),
UserToBeing: q.UserToBeing.replaceDB(db), UserToBeing: q.UserToBeing.replaceDB(db),
UserToPronoun: q.UserToPronoun.replaceDB(db), UserToPronoun: q.UserToPronoun.replaceDB(db),
UserToRole: q.UserToRole.replaceDB(db), UserToRole: q.UserToRole.replaceDB(db),
UserToTag: q.UserToTag.replaceDB(db), UserToTag: q.UserToTag.replaceDB(db),
UserToUserRelation: q.UserToUserRelation.replaceDB(db), UserToUserRelation: q.UserToUserRelation.replaceDB(db),
} }
} }
type queryCtx struct { type queryCtx struct {
AccessToken IAccessTokenDo AccessToken IAccessTokenDo
ActivitystreamsActivity IActivitystreamsActivityDo Activity IActivityDo
Collection ICollectionDo Collection ICollectionDo
Emote IEmoteDo Emote IEmoteDo
Feed IFeedDo Feed IFeedDo
LoginProcessToken ILoginProcessTokenDo LoginProcessToken ILoginProcessTokenDo
MediaMetadata IMediaMetadataDo MediaMetadata IMediaMetadataDo
Note INoteDo Note INoteDo
NoteEdit INoteEditDo NoteEdit INoteEditDo
NoteTag INoteTagDo NoteTag INoteTagDo
NoteToAttachment INoteToAttachmentDo NoteToAttachment INoteToAttachmentDo
NoteToBoost INoteToBoostDo NoteToBoost INoteToBoostDo
NoteToEmote INoteToEmoteDo NoteToEmote INoteToEmoteDo
NoteToFeed INoteToFeedDo NoteToFeed INoteToFeedDo
NoteToPing INoteToPingDo NoteToPing INoteToPingDo
Notification INotificationDo Notification INotificationDo
Reaction IReactionDo Reaction IReactionDo
RemoteServer IRemoteServerDo RemoteServer IRemoteServerDo
RemoteServerMetadata IRemoteServerMetadataDo RemoteServerMetadata IRemoteServerMetadataDo
Role IRoleDo Role IRoleDo
User IUserDo User IUserDo
UserAuthMethod IUserAuthMethodDo UserAuthMethod IUserAuthMethodDo
UserInfoField IUserInfoFieldDo UserInfoField IUserInfoFieldDo
UserRemoteLinks IUserRemoteLinksDo UserRemoteLinks IUserRemoteLinksDo
UserToBeing IUserToBeingDo UserToBeing IUserToBeingDo
UserToPronoun IUserToPronounDo UserToPronoun IUserToPronounDo
UserToRole IUserToRoleDo UserToRole IUserToRoleDo
UserToTag IUserToTagDo UserToTag IUserToTagDo
UserToUserRelation IUserToUserRelationDo UserToUserRelation IUserToUserRelationDo
} }
func (q *Query) WithContext(ctx context.Context) *queryCtx { func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{ return &queryCtx{
AccessToken: q.AccessToken.WithContext(ctx), AccessToken: q.AccessToken.WithContext(ctx),
ActivitystreamsActivity: q.ActivitystreamsActivity.WithContext(ctx), Activity: q.Activity.WithContext(ctx),
Collection: q.Collection.WithContext(ctx), Collection: q.Collection.WithContext(ctx),
Emote: q.Emote.WithContext(ctx), Emote: q.Emote.WithContext(ctx),
Feed: q.Feed.WithContext(ctx), Feed: q.Feed.WithContext(ctx),
LoginProcessToken: q.LoginProcessToken.WithContext(ctx), LoginProcessToken: q.LoginProcessToken.WithContext(ctx),
MediaMetadata: q.MediaMetadata.WithContext(ctx), MediaMetadata: q.MediaMetadata.WithContext(ctx),
Note: q.Note.WithContext(ctx), Note: q.Note.WithContext(ctx),
NoteEdit: q.NoteEdit.WithContext(ctx), NoteEdit: q.NoteEdit.WithContext(ctx),
NoteTag: q.NoteTag.WithContext(ctx), NoteTag: q.NoteTag.WithContext(ctx),
NoteToAttachment: q.NoteToAttachment.WithContext(ctx), NoteToAttachment: q.NoteToAttachment.WithContext(ctx),
NoteToBoost: q.NoteToBoost.WithContext(ctx), NoteToBoost: q.NoteToBoost.WithContext(ctx),
NoteToEmote: q.NoteToEmote.WithContext(ctx), NoteToEmote: q.NoteToEmote.WithContext(ctx),
NoteToFeed: q.NoteToFeed.WithContext(ctx), NoteToFeed: q.NoteToFeed.WithContext(ctx),
NoteToPing: q.NoteToPing.WithContext(ctx), NoteToPing: q.NoteToPing.WithContext(ctx),
Notification: q.Notification.WithContext(ctx), Notification: q.Notification.WithContext(ctx),
Reaction: q.Reaction.WithContext(ctx), Reaction: q.Reaction.WithContext(ctx),
RemoteServer: q.RemoteServer.WithContext(ctx), RemoteServer: q.RemoteServer.WithContext(ctx),
RemoteServerMetadata: q.RemoteServerMetadata.WithContext(ctx), RemoteServerMetadata: q.RemoteServerMetadata.WithContext(ctx),
Role: q.Role.WithContext(ctx), Role: q.Role.WithContext(ctx),
User: q.User.WithContext(ctx), User: q.User.WithContext(ctx),
UserAuthMethod: q.UserAuthMethod.WithContext(ctx), UserAuthMethod: q.UserAuthMethod.WithContext(ctx),
UserInfoField: q.UserInfoField.WithContext(ctx), UserInfoField: q.UserInfoField.WithContext(ctx),
UserRemoteLinks: q.UserRemoteLinks.WithContext(ctx), UserRemoteLinks: q.UserRemoteLinks.WithContext(ctx),
UserToBeing: q.UserToBeing.WithContext(ctx), UserToBeing: q.UserToBeing.WithContext(ctx),
UserToPronoun: q.UserToPronoun.WithContext(ctx), UserToPronoun: q.UserToPronoun.WithContext(ctx),
UserToRole: q.UserToRole.WithContext(ctx), UserToRole: q.UserToRole.WithContext(ctx),
UserToTag: q.UserToTag.WithContext(ctx), UserToTag: q.UserToTag.WithContext(ctx),
UserToUserRelation: q.UserToUserRelation.WithContext(ctx), UserToUserRelation: q.UserToUserRelation.WithContext(ctx),
} }
} }

View file

@ -37,6 +37,9 @@ func Migrate(db *gorm.DB) error {
if err := createActitiystreamsActivityType(db); err != nil { if err := createActitiystreamsActivityType(db); err != nil {
return other.Error("storage", "Failed to create Activitystreams Activity type", err) return other.Error("storage", "Failed to create Activitystreams Activity type", err)
} }
if err := createCollectionTarget(db); err != nil {
return other.Error("storage", "Failed t ocreate collections target type", err)
}
if err := migrateTypes(db); err != nil { if err := migrateTypes(db); err != nil {
return other.Error("storage", "Failed to automigrate data structs", err) return other.Error("storage", "Failed to automigrate data structs", err)
} }
@ -126,6 +129,17 @@ func createActitiystreamsActivityTargetType(db *gorm.DB) error {
) )
} }
func createCollectionTarget(db *gorm.DB) error {
return migrateEnum(
db,
"collection_target_type",
sliceutils.Map(
models.AllCollectionTargetTypes,
func(t models.CollectionTargetType) string { return string(t) },
),
)
}
// Helper function for ensuring the existence of an enum with the given values // Helper function for ensuring the existence of an enum with the given values
func migrateEnum(db *gorm.DB, name string, values []string) error { func migrateEnum(db *gorm.DB, name string, values []string) error {
if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil { if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil {

View file

@ -2,8 +2,8 @@ package models
// A list of all models stored in the database // A list of all models stored in the database
var AllTypes = []any{ var AllTypes = []any{
&Activity{},
&Collection{}, &Collection{},
&ActivitystreamsActivity{},
&Emote{}, &Emote{},
&Feed{}, &Feed{},
&MediaMetadata{}, &MediaMetadata{},

View file

@ -1,6 +1,6 @@
package models package models
type ActivitystreamsActivity struct { type Activity struct {
Id string `gorm:"primarykey"` Id string `gorm:"primarykey"`
Type string `gorm:"type:activitystreams_activity_type"` Type string `gorm:"type:activitystreams_activity_type"`
ObjectId string ObjectId string

View file

@ -3,5 +3,5 @@ package models
type Collection struct { type Collection struct {
Id string `gorm:"primarykey"` Id string `gorm:"primarykey"`
TargetId string TargetId string
TargetType uint32 TargetType string `orm:"type:collection_target_type"`
} }

View file

@ -0,0 +1,28 @@
package models
import "database/sql/driver"
type CollectionTargetType string
const (
CollectionTargetUnknown = CollectionTargetType("unknown")
CollectionTargetPinnedNotes = CollectionTargetType("pinned")
CollectionTargetReactions = CollectionTargetType("reactions")
CollectionTargetBoostsAndQuotes = CollectionTargetType("boosts")
)
var AllCollectionTargetTypes = []CollectionTargetType{
CollectionTargetUnknown,
CollectionTargetPinnedNotes,
CollectionTargetReactions,
CollectionTargetBoostsAndQuotes,
}
func (n *CollectionTargetType) Value() (driver.Value, error) {
return n, nil
}
func (ct *CollectionTargetType) Scan(value any) error {
*ct = CollectionTargetType(value.(uint32))
return nil
}

View file

@ -1,7 +1,7 @@
[general] [general]
protocol = "https" protocol = "https"
domain = "lhr.life" domain = "lhr.life"
subdomain = "61f6e346a99d58" subdomain = "e8adf969423370"
private_port = 8080 private_port = 8080
public_port = 443 public_port = 443

View file

@ -11,6 +11,7 @@ import (
"github.com/rs/zerolog/hlog" "github.com/rs/zerolog/hlog"
"gorm.io/gorm" "gorm.io/gorm"
"git.mstar.dev/mstar/linstrom/shared"
"git.mstar.dev/mstar/linstrom/storage-new" "git.mstar.dev/mstar/linstrom/storage-new"
"git.mstar.dev/mstar/linstrom/storage-new/dbgen" "git.mstar.dev/mstar/linstrom/storage-new/dbgen"
"git.mstar.dev/mstar/linstrom/storage-new/models" "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, AccessLevel: models.NOTE_TARGET_PUBLIC,
OriginId: 1, OriginId: 1,
} }
n.Select( err = n.Select(
n.CreatorId, n.CreatorId,
n.RawContent, n.RawContent,
n.Remote, n.Remote,
@ -74,6 +75,26 @@ func postAs(w http.ResponseWriter, r *http.Request) {
n.AccessLevel, n.AccessLevel,
n.OriginId, n.OriginId,
).Create(&note) ).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) { 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 // getting the final result
func createFromStorage(ctx context.Context, id string) (*activityCreateOut, error) { func createFromStorage(ctx context.Context, id string) (*activityCreateOut, error) {
// log := log.Ctx(ctx) // log := log.Ctx(ctx)
asa := dbgen.ActivitystreamsActivity a := dbgen.Activity
activity, err := asa.Where(asa.Type.Eq(string(models.ActivityCreate))). activity, err := a.Where(a.Type.Eq(string(models.ActivityCreate))).
Where(asa.Id.Eq(id)). Where(a.Id.Eq(id)).
First() First()
if err != nil { if err != nil {
return nil, err return nil, err