feat(components): inbox and outbox repositories

master
Xeronith 2022-11-04 16:54:07 +03:30
rodzic ef5c662cfe
commit f39909c781
5 zmienionych plików z 647 dodań i 17 usunięć

Wyświetl plik

@ -7,14 +7,16 @@ import (
// noinspection GoUnusedConst,GoSnakeCaseUsage
const (
PIPE_DOCUMENT = 0x00000001
PIPE_SYSTEM_SCHEDULE = 0x00000002
PIPE_IDENTITY = 0x00000003
PIPE_ACCESS_CONTROL = 0x00000004
PIPE_REMOTE_ACTIVITY = 0x00000005
PIPE_CATEGORY_TYPE = 0x00000006
PIPE_CATEGORY = 0x00000007
PIPE_USER = 0x00000008
PIPE_DOCUMENT = 0x00000001
PIPE_SYSTEM_SCHEDULE = 0x00000002
PIPE_IDENTITY = 0x00000003
PIPE_ACCESS_CONTROL = 0x00000004
PIPE_REMOTE_ACTIVITY = 0x00000005
PIPE_CATEGORY_TYPE = 0x00000006
PIPE_CATEGORY = 0x00000007
PIPE_USER = 0x00000008
PIPE_ACTIVITY_PUB_INCOMING_ACTIVITY = 0x0000000E
PIPE_ACTIVITY_PUB_OUTGOING_ACTIVITY = 0x0000000F
)
type (

Wyświetl plik

@ -0,0 +1,302 @@
package repository
import (
. "github.com/xeronith/diamante/contracts/database"
. "github.com/xeronith/diamante/contracts/logging"
. "rail.town/infrastructure/components/constants"
. "rail.town/infrastructure/components/contracts/model"
. "rail.town/infrastructure/components/model/entity"
)
type activityPubIncomingActivitiesRepository struct {
baseRepository
}
func newActivityPubIncomingActivitiesRepository(logger ILogger) IActivityPubIncomingActivitiesRepository {
return &activityPubIncomingActivitiesRepository{
baseRepository: newBaseRepository("activity_pub_incoming_activity", "activity_pub_incoming_activities", ActivityPubIncomingActivityEntityType, logger, false),
}
}
func (repository *activityPubIncomingActivitiesRepository) Add(entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "INSERT INTO `activity_pub_incoming_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
return repository.database.InsertSingle(query, entity.Id(), entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor)
}
func (repository *activityPubIncomingActivitiesRepository) AddAtomic(transaction IRepositoryTransaction, entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "INSERT INTO `activity_pub_incoming_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
return repository.database.InsertSingleAtomic(transaction, query, entity.Id(), entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor)
}
func (repository *activityPubIncomingActivitiesRepository) FetchById(id int64) (IActivityPubIncomingActivityEntity, error) {
if id <= 0 {
return nil, ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_incoming_activities` WHERE `id` = ? AND `status` = 0;"
var activityPubIncomingActivityEntity IActivityPubIncomingActivityEntity
if err := repository.database.QuerySingle(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubIncomingActivityEntity = NewActivityPubIncomingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw)
return nil
}, query, id); err != nil {
return nil, err
}
return activityPubIncomingActivityEntity, nil
}
func (repository *activityPubIncomingActivitiesRepository) Update(entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `identity_id` = ?, `unique_identifier` = ?, `timestamp` = ?, `from` = ?, `to` = ?, `content` = ?, `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor, entity.Id())
}
func (repository *activityPubIncomingActivitiesRepository) UpdateAtomic(transaction IRepositoryTransaction, entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `identity_id` = ?, `unique_identifier` = ?, `timestamp` = ?, `from` = ?, `to` = ?, `content` = ?, `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor, entity.Id())
}
func (repository *activityPubIncomingActivitiesRepository) Remove(entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `status` = 1, `editor` = ? WHERE `id` = ?;"
return repository.database.DeleteSingle(query, editor, entity.Id())
}
func (repository *activityPubIncomingActivitiesRepository) RemoveAtomic(transaction IRepositoryTransaction, entity IActivityPubIncomingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `status` = 1, `editor` = ? WHERE `id` = ?;"
return repository.database.DeleteSingleAtomic(transaction, query, editor, entity.Id())
}
func (repository *activityPubIncomingActivitiesRepository) FetchAll() (ActivityPubIncomingActivityEntities, error) {
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_incoming_activities` WHERE `id` > 0 AND `status` = 0;"
var activityPubIncomingActivityEntities ActivityPubIncomingActivityEntities
if err := repository.database.Query(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubIncomingActivityEntities = append(activityPubIncomingActivityEntities, NewActivityPubIncomingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw))
return nil
}, query); err != nil {
return nil, err
}
return activityPubIncomingActivityEntities, nil
}
func (repository *activityPubIncomingActivitiesRepository) FetchAllByIdentity(identityId int64) (ActivityPubIncomingActivityEntities, error) {
if identityId <= 0 {
return nil, ERROR_INVALID_PARAMETERS
}
return repository.FetchAllByDependency("identity_id", identityId)
}
func (repository *activityPubIncomingActivitiesRepository) FetchAllByDependency(dependencyName string, dependencyId int64) (ActivityPubIncomingActivityEntities, error) {
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_incoming_activities` WHERE `id` > 0 AND `status` = 0"
query += " AND `" + dependencyName + "` = ?;"
var activityPubIncomingActivityEntities ActivityPubIncomingActivityEntities
if err := repository.database.Query(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubIncomingActivityEntities = append(activityPubIncomingActivityEntities, NewActivityPubIncomingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw))
return nil
}, query, dependencyId); err != nil {
return nil, err
}
return activityPubIncomingActivityEntities, nil
}
func (repository *activityPubIncomingActivitiesRepository) UpdateUniqueIdentifier(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `unique_identifier` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateUniqueIdentifierAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `unique_identifier` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateTimestamp(id int64, value int64, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `timestamp` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateTimestampAtomic(transaction IRepositoryTransaction, id int64, value int64, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `timestamp` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateFrom(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `from` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateFromAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `from` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateTo(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `to` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateToAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `to` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateContent(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `content` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateContentAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `content` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateRaw(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubIncomingActivitiesRepository) UpdateRawAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_incoming_activities` SET `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}

Wyświetl plik

@ -0,0 +1,302 @@
package repository
import (
. "github.com/xeronith/diamante/contracts/database"
. "github.com/xeronith/diamante/contracts/logging"
. "rail.town/infrastructure/components/constants"
. "rail.town/infrastructure/components/contracts/model"
. "rail.town/infrastructure/components/model/entity"
)
type activityPubOutgoingActivitiesRepository struct {
baseRepository
}
func newActivityPubOutgoingActivitiesRepository(logger ILogger) IActivityPubOutgoingActivitiesRepository {
return &activityPubOutgoingActivitiesRepository{
baseRepository: newBaseRepository("activity_pub_outgoing_activity", "activity_pub_outgoing_activities", ActivityPubOutgoingActivityEntityType, logger, false),
}
}
func (repository *activityPubOutgoingActivitiesRepository) Add(entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "INSERT INTO `activity_pub_outgoing_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
return repository.database.InsertSingle(query, entity.Id(), entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor)
}
func (repository *activityPubOutgoingActivitiesRepository) AddAtomic(transaction IRepositoryTransaction, entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "INSERT INTO `activity_pub_outgoing_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
return repository.database.InsertSingleAtomic(transaction, query, entity.Id(), entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor)
}
func (repository *activityPubOutgoingActivitiesRepository) FetchById(id int64) (IActivityPubOutgoingActivityEntity, error) {
if id <= 0 {
return nil, ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_outgoing_activities` WHERE `id` = ? AND `status` = 0;"
var activityPubOutgoingActivityEntity IActivityPubOutgoingActivityEntity
if err := repository.database.QuerySingle(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubOutgoingActivityEntity = NewActivityPubOutgoingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw)
return nil
}, query, id); err != nil {
return nil, err
}
return activityPubOutgoingActivityEntity, nil
}
func (repository *activityPubOutgoingActivitiesRepository) Update(entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `identity_id` = ?, `unique_identifier` = ?, `timestamp` = ?, `from` = ?, `to` = ?, `content` = ?, `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor, entity.Id())
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateAtomic(transaction IRepositoryTransaction, entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `identity_id` = ?, `unique_identifier` = ?, `timestamp` = ?, `from` = ?, `to` = ?, `content` = ?, `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, entity.IdentityId(), entity.UniqueIdentifier(), entity.Timestamp(), entity.From(), entity.To(), entity.Content(), entity.Raw(), editor, entity.Id())
}
func (repository *activityPubOutgoingActivitiesRepository) Remove(entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `status` = 1, `editor` = ? WHERE `id` = ?;"
return repository.database.DeleteSingle(query, editor, entity.Id())
}
func (repository *activityPubOutgoingActivitiesRepository) RemoveAtomic(transaction IRepositoryTransaction, entity IActivityPubOutgoingActivityEntity, editor int64) error {
if entity.Id() <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `status` = 1, `editor` = ? WHERE `id` = ?;"
return repository.database.DeleteSingleAtomic(transaction, query, editor, entity.Id())
}
func (repository *activityPubOutgoingActivitiesRepository) FetchAll() (ActivityPubOutgoingActivityEntities, error) {
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_outgoing_activities` WHERE `id` > 0 AND `status` = 0;"
var activityPubOutgoingActivityEntities ActivityPubOutgoingActivityEntities
if err := repository.database.Query(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubOutgoingActivityEntities = append(activityPubOutgoingActivityEntities, NewActivityPubOutgoingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw))
return nil
}, query); err != nil {
return nil, err
}
return activityPubOutgoingActivityEntities, nil
}
func (repository *activityPubOutgoingActivitiesRepository) FetchAllByIdentity(identityId int64) (ActivityPubOutgoingActivityEntities, error) {
if identityId <= 0 {
return nil, ERROR_INVALID_PARAMETERS
}
return repository.FetchAllByDependency("identity_id", identityId)
}
func (repository *activityPubOutgoingActivitiesRepository) FetchAllByDependency(dependencyName string, dependencyId int64) (ActivityPubOutgoingActivityEntities, error) {
// language=SQL
query := "SELECT `id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw` FROM `activity_pub_outgoing_activities` WHERE `id` > 0 AND `status` = 0"
query += " AND `" + dependencyName + "` = ?;"
var activityPubOutgoingActivityEntities ActivityPubOutgoingActivityEntities
if err := repository.database.Query(func(cursor ICursor) error {
var (
id int64
identityId int64
uniqueIdentifier string
timestamp int64
from string
to string
content string
raw string
)
if err := cursor.Scan(&id, &identityId, &uniqueIdentifier, &timestamp, &from, &to, &content, &raw); err != nil {
return err
}
activityPubOutgoingActivityEntities = append(activityPubOutgoingActivityEntities, NewActivityPubOutgoingActivityEntity(id, identityId, uniqueIdentifier, timestamp, from, to, content, raw))
return nil
}, query, dependencyId); err != nil {
return nil, err
}
return activityPubOutgoingActivityEntities, nil
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateUniqueIdentifier(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `unique_identifier` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateUniqueIdentifierAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `unique_identifier` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateTimestamp(id int64, value int64, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `timestamp` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateTimestampAtomic(transaction IRepositoryTransaction, id int64, value int64, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `timestamp` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateFrom(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `from` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateFromAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `from` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateTo(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `to` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateToAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `to` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateContent(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `content` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateContentAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `content` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateRaw(id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingle(query, value, editor, id)
}
func (repository *activityPubOutgoingActivitiesRepository) UpdateRawAtomic(transaction IRepositoryTransaction, id int64, value string, editor int64) error {
if id <= 0 {
return ERROR_INVALID_PARAMETERS
}
// language=SQL
query := "UPDATE `activity_pub_outgoing_activities` SET `raw` = ?, `editor` = ? WHERE `id` = ?;"
return repository.database.UpdateSingleAtomic(transaction, query, value, editor, id)
}

Wyświetl plik

@ -12,15 +12,17 @@ import (
)
var (
Pipe IPipeRepository
Documents IDocumentsRepository
SystemSchedules ISystemSchedulesRepository
Identities IIdentitiesRepository
AccessControls IAccessControlsRepository
RemoteActivities IRemoteActivitiesRepository
CategoryTypes ICategoryTypesRepository
Categories ICategoriesRepository
Users IUsersRepository
Pipe IPipeRepository
Documents IDocumentsRepository
SystemSchedules ISystemSchedulesRepository
Identities IIdentitiesRepository
AccessControls IAccessControlsRepository
RemoteActivities IRemoteActivitiesRepository
CategoryTypes ICategoryTypesRepository
Categories ICategoriesRepository
Users IUsersRepository
ActivityPubIncomingActivities IActivityPubIncomingActivitiesRepository
ActivityPubOutgoingActivities IActivityPubOutgoingActivitiesRepository
)
var database ISqlDatabase
@ -45,6 +47,8 @@ func Initialize(configuration IConfiguration, logger ILogger) error {
CategoryTypes = newCategoryTypesRepository(logger)
Categories = newCategoriesRepository(logger)
Users = newUsersRepository(logger)
ActivityPubIncomingActivities = newActivityPubIncomingActivitiesRepository(logger)
ActivityPubOutgoingActivities = newActivityPubOutgoingActivitiesRepository(logger)
repositories := []IRepository{
Pipe,
@ -56,6 +60,8 @@ func Initialize(configuration IConfiguration, logger ILogger) error {
CategoryTypes,
Categories,
Users,
ActivityPubIncomingActivities,
ActivityPubOutgoingActivities,
}
for _, repository := range repositories {

Wyświetl plik

@ -82,6 +82,24 @@ func (repository *pipeRepository) GetPipeDescriptors() []*pipeDescriptor {
return Parameters{e.Id(), e.Github(), e.GetEditor(), e.GetQueueTimestamp().UnixNano(), e.Payload()}
},
},
{
PIPE_ACTIVITY_PUB_INCOMING_ACTIVITY,
&sync.Mutex{},
"INSERT INTO `activity_pub_incoming_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `queued_at`, `payload`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
func(entity IPipeEntity) Parameters {
e := entity.(IActivityPubIncomingActivityPipeEntity)
return Parameters{e.Id(), e.IdentityId(), e.UniqueIdentifier(), e.Timestamp(), e.From(), e.To(), e.Content(), e.Raw(), e.GetEditor(), e.GetQueueTimestamp().UnixNano(), e.Payload()}
},
},
{
PIPE_ACTIVITY_PUB_OUTGOING_ACTIVITY,
&sync.Mutex{},
"INSERT INTO `activity_pub_outgoing_activities` (`id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `queued_at`, `payload`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
func(entity IPipeEntity) Parameters {
e := entity.(IActivityPubOutgoingActivityPipeEntity)
return Parameters{e.Id(), e.IdentityId(), e.UniqueIdentifier(), e.Timestamp(), e.From(), e.To(), e.Content(), e.Raw(), e.GetEditor(), e.GetQueueTimestamp().UnixNano(), e.Payload()}
},
},
}
return descriptors