snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
155
server/pkg/federation/social.go
Normal file
155
server/pkg/federation/social.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package federation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/options"
|
||||
)
|
||||
|
||||
type (
|
||||
EncoderAdapterActivityStreams struct{}
|
||||
)
|
||||
|
||||
// Build an activity streams format from default internal Corteza
|
||||
// payload, including the author, activitystreams metadata and paging
|
||||
// custom metadata
|
||||
func (a EncoderAdapterActivityStreams) BuildStructure(w io.Writer, o options.FederationOpt, p interface{}) (interface{}, error) {
|
||||
var (
|
||||
next, prev *listResponsePagingActivityStreams
|
||||
items []listResponseItemActivityStreams
|
||||
)
|
||||
|
||||
payload := p.(ListStructurePayload)
|
||||
|
||||
if payload.Filter.Paging.NextPage != nil {
|
||||
next = &listResponsePagingActivityStreams{
|
||||
Type: "Link",
|
||||
Name: "Next page",
|
||||
Href: fmt.Sprintf("https://%s/nodes/%d/modules/exposed/?pageCursor=%s", o.Host, payload.NodeID, payload.Filter.Paging.NextPage.Encode()),
|
||||
}
|
||||
}
|
||||
|
||||
if payload.Filter.Paging.PrevPage != nil {
|
||||
prev = &listResponsePagingActivityStreams{
|
||||
Type: "Link",
|
||||
Name: "Previous page",
|
||||
Href: fmt.Sprintf("https://%s/nodes/%d/modules/exposed/?pageCursor=%s", o.Host, payload.NodeID, payload.Filter.Paging.PrevPage.Encode()),
|
||||
}
|
||||
}
|
||||
|
||||
// loop through items and format them
|
||||
for _, v := range *payload.Set {
|
||||
item := listResponseItemActivityStreams{
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
Type: "Module",
|
||||
Summary: fmt.Sprintf("Structure for module %s on node %d", v.Name, v.NodeID),
|
||||
Url: fmt.Sprintf("https://%s/nodes/%d/modules/%d", o.Host, v.NodeID, v.ID),
|
||||
Name: v.Name,
|
||||
Handle: v.Handle,
|
||||
Node: v.NodeID,
|
||||
FederationModule: v.ID,
|
||||
ComposeModule: v.ComposeModuleID,
|
||||
ComposeNamespace: v.ComposeNamespaceID,
|
||||
|
||||
Attribution: []listResponseItemAttribution{
|
||||
{
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
Type: "User",
|
||||
Id: fmt.Sprintf("https://%s/system/users/%d", o.Host, v.CreatedBy),
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: v.CreatedAt,
|
||||
CreatedBy: v.CreatedBy,
|
||||
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
UpdatedBy: v.UpdatedBy,
|
||||
|
||||
DeletedAt: v.DeletedAt,
|
||||
DeletedBy: v.DeletedBy,
|
||||
|
||||
Fields: v.Fields,
|
||||
}
|
||||
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
return listModuleResponseActivityStreams{
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
ItemsPerPage: payload.Filter.Limit,
|
||||
Items: items,
|
||||
Next: next,
|
||||
Prev: prev,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Build an activity streams format from default internal Corteza
|
||||
// payload, including the author, activitystreams metadata and paging
|
||||
// custom metadata
|
||||
func (a EncoderAdapterActivityStreams) BuildData(w io.Writer, o options.FederationOpt, p interface{}) (interface{}, error) {
|
||||
var (
|
||||
next, prev *listResponsePagingActivityStreams
|
||||
items []listResponseItemActivityStreams
|
||||
)
|
||||
|
||||
payload := p.(ListDataPayload)
|
||||
|
||||
if payload.Filter.Paging.NextPage != nil {
|
||||
next = &listResponsePagingActivityStreams{
|
||||
Type: "Link",
|
||||
Name: "Next page",
|
||||
Href: fmt.Sprintf("https://%s/nodes/%d/modules/%d/records/social/?pageCursor=%s", o.Host, payload.NodeID, payload.ModuleID, payload.Filter.Paging.NextPage.Encode()),
|
||||
}
|
||||
}
|
||||
|
||||
if payload.Filter.Paging.PrevPage != nil {
|
||||
prev = &listResponsePagingActivityStreams{
|
||||
Type: "Link",
|
||||
Name: "Previous page",
|
||||
Href: fmt.Sprintf("https://%s/nodes/%d/modules/%d/records/social/?pageCursor=%s", o.Host, payload.NodeID, payload.ModuleID, payload.Filter.Paging.PrevPage.Encode()),
|
||||
}
|
||||
}
|
||||
|
||||
// loop through items and format them
|
||||
for _, v := range *payload.Set {
|
||||
item := listResponseItemActivityStreams{
|
||||
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
Type: "Record",
|
||||
Summary: fmt.Sprintf("Data for module %d on node %d", v.ModuleID, payload.NodeID),
|
||||
Url: fmt.Sprintf("https://%s/nodes/%d/modules/%d/records/social/", o.Host, payload.NodeID, payload.ModuleID),
|
||||
Node: payload.NodeID,
|
||||
FederationModule: v.ModuleID,
|
||||
ComposeModule: v.ModuleID,
|
||||
ComposeNamespace: v.NamespaceID,
|
||||
Attribution: []listResponseItemAttribution{
|
||||
{
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
Type: "User",
|
||||
Id: fmt.Sprintf("https://%s/system/users/%d", o.Host, v.CreatedBy),
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: v.CreatedAt,
|
||||
CreatedBy: v.CreatedBy,
|
||||
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
UpdatedBy: v.UpdatedBy,
|
||||
|
||||
DeletedAt: v.DeletedAt,
|
||||
DeletedBy: v.DeletedBy,
|
||||
Values: v.Values,
|
||||
}
|
||||
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
return listModuleResponseActivityStreams{
|
||||
Context: "https://www.w3.org/ns/activitystreams",
|
||||
ItemsPerPage: payload.Filter.Limit,
|
||||
Items: items,
|
||||
Next: next,
|
||||
Prev: prev,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user