From 9d05626729e3f7d73bb91ea852a55730a439eb98 Mon Sep 17 00:00:00 2001 From: Andrei Kurilov <18027129+akurilov@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:27:57 +0300 Subject: [PATCH] feat: awakari.app instance --- config/config.go | 5 +++-- helm/int-activitypub/templates/deployment.yaml | 2 ++ helm/int-activitypub/values-awakari-app.yaml | 4 +++- service/converter/service.go | 10 ++++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index 8aa7549..efc886f 100644 --- a/config/config.go +++ b/config/config.go @@ -11,8 +11,9 @@ type Config struct { Host string `envconfig:"API_HTTP_HOST" required:"true"` Port uint16 `envconfig:"API_HTTP_PORT" default:"8080" required:"true"` } - Port uint16 `envconfig:"API_PORT" default:"50051" required:"true"` - Writer struct { + Port uint16 `envconfig:"API_PORT" default:"50051" required:"true"` + EventType string `envconfig:"API_EVENT_TYPE" required:"true" default:"com.awakari.activitypub.v1"` + Writer struct { Backoff time.Duration `envconfig:"API_WRITER_BACKOFF" default:"10s" required:"true"` BatchSize uint32 `envconfig:"API_WRITER_BATCH_SIZE" default:"16" required:"true"` Uri string `envconfig:"API_WRITER_URI" default:"resolver:50051" required:"true"` diff --git a/helm/int-activitypub/templates/deployment.yaml b/helm/int-activitypub/templates/deployment.yaml index e5f1a68..6c51e43 100644 --- a/helm/int-activitypub/templates/deployment.yaml +++ b/helm/int-activitypub/templates/deployment.yaml @@ -38,6 +38,8 @@ spec: - name: API_HTTP_HOST value: "{{ .host }}" {{- end }} + - name: API_EVENT_TYPE + value: "{{ .Values.api.event.type }}" - name: API_WRITER_BACKOFF value: "{{ .Values.api.writer.backoff }}" - name: API_WRITER_BATCH_SIZE diff --git a/helm/int-activitypub/values-awakari-app.yaml b/helm/int-activitypub/values-awakari-app.yaml index 25f394b..eea8f5f 100644 --- a/helm/int-activitypub/values-awakari-app.yaml +++ b/helm/int-activitypub/values-awakari-app.yaml @@ -1,4 +1,6 @@ api: + event: + type: "app.awakari.activitypub.v1" writer: uri: "api:50051" @@ -7,7 +9,7 @@ cert: acme: server: "https://acme-v02.api.letsencrypt.org/directory" issuer: - name: letsencrypt + name: letsencrypt-awakari-app ingressHttpV1: hosts: diff --git a/service/converter/service.go b/service/converter/service.go index dd507b4..1aaa969 100644 --- a/service/converter/service.go +++ b/service/converter/service.go @@ -18,9 +18,9 @@ type Service interface { } type service struct { + ceType string } -const CeType = "com.awakari.activitypub.v1" const CeSpecVersion = "1.0" const CeKeyAction = "action" const CeKeyAttachmentUrl = "attachmenturl" @@ -49,8 +49,10 @@ const asPublic = "https://www.w3.org/ns/activitystreams#Public" var ErrFail = errors.New("failed to convert") -func NewService() Service { - return service{} +func NewService(ceType string) Service { + return service{ + ceType: ceType, + } } func (svc service) Convert(ctx context.Context, actor vocab.Actor, activity vocab.Activity, tags util.ActivityTags) (evt *pb.CloudEvent, err error) { @@ -59,7 +61,7 @@ func (svc service) Convert(ctx context.Context, actor vocab.Actor, activity voca Id: uuid.NewString(), Source: actor.ID.String(), SpecVersion: CeSpecVersion, - Type: CeType, + Type: svc.ceType, Attributes: map[string]*pb.CloudEventAttributeValue{ CeKeyTime: { Attr: &pb.CloudEventAttributeValue_CeTimestamp{