mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-25 07:08:47 -05:00
Compare commits
175 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d8cad17d4 | ||
|
|
790a241d9c | ||
|
|
dc7df401aa | ||
|
|
3da68555f7 | ||
|
|
6ff5b1a31d | ||
|
|
5dc1f28e87 | ||
|
|
42cce92e8f | ||
|
|
25068ada8d | ||
|
|
e7d557ca61 | ||
|
|
8ae4694253 | ||
|
|
d0effed4b5 | ||
|
|
dfda4b3a9a | ||
|
|
aa95437f59 | ||
|
|
14bd930b92 | ||
|
|
6a5c90e6d6 | ||
|
|
282bee59fe | ||
|
|
225f6f6b64 | ||
|
|
ae9c8dc653 | ||
|
|
1ea251c4ea | ||
|
|
9f65d90579 | ||
|
|
5dc9f71040 | ||
|
|
e27df2cdc9 | ||
|
|
b8f60f365b | ||
|
|
a6aeb78cfb | ||
|
|
b30585503f | ||
|
|
457e0d15d3 | ||
|
|
29d9071a09 | ||
|
|
346500801d | ||
|
|
abd7a37a7b | ||
|
|
000b7b209b | ||
|
|
db3efe6975 | ||
|
|
dce5b16936 | ||
|
|
4c1b887f65 | ||
|
|
d53f7be95a | ||
|
|
0b393de47f | ||
|
|
e36dff994c | ||
|
|
18027f14e0 | ||
|
|
9275ff1527 | ||
|
|
e9fb96e55f | ||
|
|
26317a1855 | ||
|
|
3cddb65e24 | ||
|
|
f2e515638c | ||
|
|
43c11075b7 | ||
|
|
f15681c50a | ||
|
|
85305136f8 | ||
|
|
ed730b023c | ||
|
|
0fdc5a01df | ||
|
|
276209c616 | ||
|
|
1f59143652 | ||
|
|
84ce6b2320 | ||
|
|
5e61c03696 | ||
|
|
2358e61733 | ||
|
|
ed605f92b4 | ||
|
|
d80db93332 | ||
|
|
46f8d27e42 | ||
|
|
8a97320494 | ||
|
|
0507779211 | ||
|
|
4dfed5a43e | ||
|
|
f024c2c9a9 | ||
|
|
0d23867d54 | ||
|
|
1845fa86f4 | ||
|
|
df8b42451a | ||
|
|
633679c8de | ||
|
|
cb2c6dc661 | ||
|
|
b580392a4c | ||
|
|
4cb8a8ae18 | ||
|
|
ecc9e6b34f | ||
|
|
f1972e0e23 | ||
|
|
2efc4fdfce | ||
|
|
d3cb741e44 | ||
|
|
73fd7e0f78 | ||
|
|
96fcf961b8 | ||
|
|
f5ac62859a | ||
|
|
051b483def | ||
|
|
d470b5176b | ||
|
|
925d9b894b | ||
|
|
3da0debdec | ||
|
|
197c8543f2 | ||
|
|
11a69969f6 | ||
|
|
d7b675251d | ||
|
|
996bc858c7 | ||
|
|
b369f8b415 | ||
|
|
7587c54e4e | ||
|
|
e6abc2d8ff | ||
|
|
0052d6fc4f | ||
|
|
2343e7fa83 | ||
|
|
d95b9a8e8f | ||
|
|
a5701ceb83 | ||
|
|
d79f0b3829 | ||
|
|
abb57193ff | ||
|
|
01b4a1f751 | ||
|
|
17b281cadf | ||
|
|
f4f24664ad | ||
|
|
101f38dd0b | ||
|
|
ebd51dba3b | ||
|
|
ed488b5a01 | ||
|
|
2c6ff6cd9e | ||
|
|
eeccb56d19 | ||
|
|
04b038a129 | ||
|
|
09f69c5a62 | ||
|
|
85fed11797 | ||
|
|
0e3e9607c3 | ||
|
|
e2c9350ea1 | ||
|
|
5cc98f0792 | ||
|
|
4fee45379b | ||
|
|
2ea8afeb74 | ||
|
|
c4a16e3e9a | ||
|
|
a65a59b2d0 | ||
|
|
21ea094d99 | ||
|
|
431a5ab3de | ||
|
|
1d94e3811e | ||
|
|
3cb78ed31b | ||
|
|
d54e27dcdf | ||
|
|
c31d7c57bb | ||
|
|
3026ddb255 | ||
|
|
c4fb13b263 | ||
|
|
df21fdf2e2 | ||
|
|
6224ded8b5 | ||
|
|
0da72cf346 | ||
|
|
aab08dd3de | ||
|
|
f470462ead | ||
|
|
62cace14fe | ||
|
|
a8c2beac3a | ||
|
|
1b732b8bff | ||
|
|
33cc3365ee | ||
|
|
3e48284295 | ||
|
|
c9a4bb94cd | ||
|
|
3ac4bcfeeb | ||
|
|
58583a66bb | ||
|
|
1d6433f1c9 | ||
|
|
fc938bc4bc | ||
|
|
724c44567b | ||
|
|
1fc75a9091 | ||
|
|
5b51804744 | ||
|
|
0f3dac0280 | ||
|
|
d214cfa2b7 | ||
|
|
f97bc0e875 | ||
|
|
72ee47fdca | ||
|
|
8d9c3b0c4e | ||
|
|
084eb005e3 | ||
|
|
2bdbc5a42e | ||
|
|
0a5d13b916 | ||
|
|
446a98dd62 | ||
|
|
e6441e58d4 | ||
|
|
a64223fe7d | ||
|
|
6e4918b50b | ||
|
|
ac8d2587c9 | ||
|
|
0d2a5e992c | ||
|
|
1b9249ecba | ||
|
|
94c932d6a7 | ||
|
|
8be4d11a5e | ||
|
|
2191b1d011 | ||
|
|
07522ce79a | ||
|
|
d544efdec7 | ||
|
|
8df4ef67a2 | ||
|
|
2412e64cc5 | ||
|
|
3f8076aa46 | ||
|
|
5920291ec7 | ||
|
|
772a902f6d | ||
|
|
e0ea733489 | ||
|
|
22e51bd4a1 | ||
|
|
0f47e3aca8 | ||
|
|
b3766abba5 | ||
|
|
71cddaaf3c | ||
|
|
a6cdb4e863 | ||
|
|
02f33bd1d8 | ||
|
|
ebd58fcfdb | ||
|
|
4e6053cdbd | ||
|
|
4cf4d44321 | ||
|
|
da9ed5f44b | ||
|
|
6da208e754 | ||
|
|
6620313b43 | ||
|
|
72af257cbd | ||
|
|
d638fba8c2 | ||
|
|
0435d5679d |
14
.make/go.mk
14
.make/go.mk
@@ -36,18 +36,8 @@ ifndef DATE
|
||||
DATE := $(shell date -u '+%Y%m%d')
|
||||
endif
|
||||
|
||||
LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w \
|
||||
-X "$(OC_REPO)/pkg/version.Edition=$(EDITION)" \
|
||||
-X "$(OC_REPO)/pkg/version.String=$(STRING)" \
|
||||
-X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" \
|
||||
-X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
|
||||
DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn \
|
||||
-X "$(OC_REPO)/pkg/version.Edition=$(EDITION)" \
|
||||
-X "$(OC_REPO)/pkg/version.String=$(STRING)" \
|
||||
-X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" \
|
||||
-X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
|
||||
LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w -X "$(OC_REPO)/pkg/version.String=$(STRING)" -X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" -X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -X "$(OC_REPO)/pkg/version.String=$(STRING)" -X "$(OC_REPO)/pkg/version.Tag=$(VERSION)" -X "$(OC_REPO)/pkg/version.Date=$(DATE)"
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathValue=/var/lib/opencloud"
|
||||
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathValue=/etc/opencloud"
|
||||
|
||||
|
||||
132
.vscode/launch.json
vendored
132
.vscode/launch.json
vendored
@@ -76,6 +76,138 @@
|
||||
"OC_SERVICE_ACCOUNT_SECRET": "service-account-secret"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OpenCloud server with Groupware",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"buildFlags": [
|
||||
// "-tags", "enable_vips"
|
||||
],
|
||||
"program": "${workspaceFolder}/opencloud/cmd/opencloud",
|
||||
"args": ["server"],
|
||||
"env": {
|
||||
// log settings for human developers
|
||||
"OC_LOG_LEVEL": "info",
|
||||
"OC_LOG_PRETTY": "true",
|
||||
"OC_LOG_COLOR": "true",
|
||||
// set insecure options because we don't have valid certificates in dev environments
|
||||
"OC_INSECURE": "true",
|
||||
// enable basic auth for dev setup so that we can use curl for testing
|
||||
"PROXY_ENABLE_BASIC_AUTH": "true",
|
||||
// demo users
|
||||
"IDM_CREATE_DEMO_USERS": "true",
|
||||
// OC_RUN_SERVICES allows to start a subset of services even in the supervised mode
|
||||
//"OC_RUN_SERVICES": "settings,storage-system,graph,idp,idm,ocs,store,thumbnails,web,webdav,frontend,gateway,users,groups,auth-basic,storage-authmachine,storage-users,storage-shares,storage-publiclink,storage-system,app-provider,sharing,proxy,ocdav",
|
||||
|
||||
/*
|
||||
* Keep secrets and passwords in one block to allow easy uncommenting
|
||||
*/
|
||||
// user id of "admin", for user creation and admin role assignement
|
||||
"OC_ADMIN_USER_ID": "some-admin-user-id-0000-000000000000", // FIXME currently must have the length of a UUID, see reva/pkg/storage/utils/decomposedfs/spaces.go:228
|
||||
// admin user default password
|
||||
"IDM_ADMIN_PASSWORD": "admin",
|
||||
// system user
|
||||
"OC_SYSTEM_USER_ID": "some-system-user-id-000-000000000000", // FIXME currently must have the length of a UUID, see reva/pkg/storage/utils/decomposedfs/spaces.go:228
|
||||
"OC_SYSTEM_USER_API_KEY": "some-system-user-machine-auth-api-key",
|
||||
// set some hardcoded secrets
|
||||
"OC_JWT_SECRET": "some-opencloud-jwt-secret",
|
||||
"OC_MACHINE_AUTH_API_KEY": "some-opencloud-machine-auth-api-key",
|
||||
"OC_TRANSFER_SECRET": "some-opencloud-transfer-secret",
|
||||
// collaboration
|
||||
"COLLABORATION_WOPIAPP_SECRET": "some-wopi-secret",
|
||||
// idm ldap
|
||||
"IDM_SVC_PASSWORD": "some-ldap-idm-password",
|
||||
"GRAPH_LDAP_BIND_PASSWORD": "some-ldap-idm-password",
|
||||
// reva ldap
|
||||
"IDM_REVASVC_PASSWORD": "some-ldap-reva-password",
|
||||
"GROUPS_LDAP_BIND_PASSWORD": "some-ldap-reva-password",
|
||||
"USERS_LDAP_BIND_PASSWORD": "some-ldap-reva-password",
|
||||
"AUTH_BASIC_LDAP_BIND_PASSWORD": "some-ldap-reva-password",
|
||||
// idp ldap
|
||||
"IDM_IDPSVC_PASSWORD": "some-ldap-idp-password",
|
||||
"IDP_LDAP_BIND_PASSWORD": "some-ldap-idp-password",
|
||||
// storage users mount ID
|
||||
"GATEWAY_STORAGE_USERS_MOUNT_ID": "storage-users-1",
|
||||
"STORAGE_USERS_MOUNT_ID": "storage-users-1",
|
||||
// graph application ID
|
||||
"GRAPH_APPLICATION_ID": "application-1",
|
||||
|
||||
// service accounts
|
||||
"OC_SERVICE_ACCOUNT_ID": "service-account-id",
|
||||
"OC_SERVICE_ACCOUNT_SECRET": "service-account-secret",
|
||||
|
||||
"OC_ADD_RUN_SERVICES": "groupware",
|
||||
"GROUPWARE_LOG_LEVEL": "trace"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OpenCloud server with external services",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"buildFlags": [
|
||||
// "-tags", "enable_vips"
|
||||
],
|
||||
"program": "${workspaceFolder}/opencloud/cmd/opencloud",
|
||||
"args": ["server"],
|
||||
"env": {
|
||||
"OC_URL": "https://localhost:9200/",
|
||||
"PROXY_DEBUG_ADDR": "0.0.0.0:9205",
|
||||
"OC_BASE_DATA_PATH": "${env:HOME}/.opencloud-with-external",
|
||||
"OC_CONFIG_DIR": "${env:HOME}/.opencloud-with-external/config",
|
||||
"GROUPWARE_LOG_LEVEL": "trace",
|
||||
"OC_LOG_LEVEL": "info",
|
||||
"OC_LOG_PRETTY": "true",
|
||||
"OC_LOG_COLOR": "true",
|
||||
"OC_INSECURE": "true",
|
||||
"PROXY_ENABLE_BASIC_AUTH": "false",
|
||||
"IDM_CREATE_DEMO_USERS": "false",
|
||||
"OC_LDAP_URI": "ldaps://localhost:636",
|
||||
"OC_LDAP_INSECURE": "true",
|
||||
"OC_LDAP_BIND_DN": "cn=admin,dc=opencloud,dc=eu",
|
||||
"OC_LDAP_BIND_PASSWORD": "admin",
|
||||
"OC_LDAP_GROUP_BASE_DN": "ou=groups,dc=opencloud,dc=eu",
|
||||
"OC_LDAP_GROUP_SCHEMA_ID": "entryUUID",
|
||||
"OC_LDAP_USER_BASE_DN": "ou=users,dc=opencloud,dc=eu",
|
||||
"OC_LDAP_USER_FILTER": "(objectclass=inetOrgPerson)",
|
||||
"OC_LDAP_USER_SCHEMA_ID": "entryUUID",
|
||||
"OC_LDAP_DISABLE_USER_MECHANISM": "none",
|
||||
"OC_LDAP_SERVER_WRITE_ENABLED": "false",
|
||||
"OC_EXCLUDE_RUN_SERVICES": "idm",
|
||||
"OC_ADD_RUN_SERVICES": "notifications,groupware",
|
||||
"NATS_NATS_HOST": "0.0.0.0",
|
||||
"NATS_NATS_PORT": "9233",
|
||||
"FRONTEND_ARCHIVER_MAX_SIZE": "10000000000",
|
||||
"MICRO_REGISTRY_ADDRESS": "127.0.0.1:9233",
|
||||
"NOTIFICATIONS_SMTP_HOST": "localhost",
|
||||
"NOTIFICATIONS_SMTP_PORT": "2500",
|
||||
"NOTIFICATIONS_SMTP_SENDER": "OpenCloud notifications <notifications@cloud.opencloud.test>",
|
||||
"NOTIFICATIONS_SMTP_USERNAME": "notifications@cloud.opencloud.test",
|
||||
"NOTIFICATIONS_SMTP_INSECURE": "true",
|
||||
"NOTIFICATIONS_SMTP_PASSWORD": "",
|
||||
"NOTIFICATIONS_SMTP_AUTHENTICATION": "",
|
||||
"NOTIFICATIONS_SMTP_ENCRYPTION": "none",
|
||||
"PROXY_AUTOPROVISION_ACCOUNTS": "false",
|
||||
"PROXY_ROLE_ASSIGNMENT_DRIVER": "oidc",
|
||||
"OC_OIDC_ISSUER": "https://keycloak.opencloud.test/realms/openCloud",
|
||||
"PROXY_OIDC_REWRITE_WELLKNOWN": "true",
|
||||
"WEB_OIDC_CLIENT_ID": "web",
|
||||
"PROXY_USER_OIDC_CLAIM": "uuid",
|
||||
"PROXY_USER_CS3_CLAIM": "userid",
|
||||
"WEB_OPTION_ACCOUNT_EDIT_LINK_HREF": "https://keycloak.opencloud.test/realms/openCloud/account",
|
||||
"OC_ADMIN_USER_ID": "",
|
||||
"SETTINGS_SETUP_DEFAULT_ASSIGNMENTS": "false",
|
||||
"GRAPH_ASSIGN_DEFAULT_USER_ROLE": "false",
|
||||
"GRAPH_USERNAME_MATCH": "none",
|
||||
"KEYCLOAK_DOMAIN": "keycloak.opencloud.test",
|
||||
"IDM_ADMIN_PASSWORD": "admin",
|
||||
"GRAPH_LDAP_SERVER_UUID": "true",
|
||||
"GRAPH_LDAP_GROUP_CREATE_BASE_DN": "ou=custom,ou=groups,dc=opencloud,dc=eu",
|
||||
"GRAPH_LDAP_REFINT_ENABLED": "true",
|
||||
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Fed OpenCloud server",
|
||||
"type": "go",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# The test runner source for UI tests
|
||||
WEB_COMMITID=3120ea384c7a9d1f1ea0c328965951fc06d66900
|
||||
WEB_BRANCH=main
|
||||
WEB_COMMITID=50e3fff6a518361d59cba864a927470f313b6f91
|
||||
WEB_BRANCH=stable-4.2
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
# Repository
|
||||
|
||||
repo_slug = "${CI_REPO}"
|
||||
repo_slug = "opencloud-eu/opencloud"
|
||||
docker_repo_slug = "opencloudeu/opencloud"
|
||||
|
||||
# images
|
||||
@@ -43,19 +43,19 @@ DEFAULT_NODEJS_VERSION = "20"
|
||||
CACHE_S3_SERVER = "https://s3.ci.opencloud.eu"
|
||||
|
||||
dirs = {
|
||||
"base": "/woodpecker/src/github.com/%s" % repo_slug,
|
||||
"web": "/woodpecker/src/github.com/%s/webTestRunner" % repo_slug,
|
||||
"zip": "/woodpecker/src/github.com/%s/zip" % repo_slug,
|
||||
"webZip": "/woodpecker/src/github.com/%s/zip/web.tar.gz" % repo_slug,
|
||||
"webPnpmZip": "/woodpecker/src/github.com/%s/zip/web-pnpm.tar.gz" % repo_slug,
|
||||
"playwrightBrowsersArchive": "/woodpecker/src/github.com/%s/zip/playwright-browsers.tar.gz" % repo_slug,
|
||||
"baseGo": "/go/src/github.com/%s" % repo_slug,
|
||||
"base": "/woodpecker/src/github.com/opencloud-eu/opencloud",
|
||||
"web": "/woodpecker/src/github.com/opencloud-eu/opencloud/webTestRunner",
|
||||
"zip": "/woodpecker/src/github.com/opencloud-eu/opencloud/zip",
|
||||
"webZip": "/woodpecker/src/github.com/opencloud-eu/opencloud/zip/web.tar.gz",
|
||||
"webPnpmZip": "/woodpecker/src/github.com/opencloud-eu/opencloud/zip/web-pnpm.tar.gz",
|
||||
"playwrightBrowsersArchive": "/woodpecker/src/github.com/opencloud-eu/opencloud/zip/playwright-browsers.tar.gz",
|
||||
"baseGo": "/go/src/github.com/opencloud-eu/opencloud",
|
||||
"gobinTar": "go-bin.tar.gz",
|
||||
"gobinTarPath": "/go/src/github.com/%s/go-bin.tar.gz" % repo_slug,
|
||||
"gobinTarPath": "/go/src/github.com/opencloud-eu/opencloud/go-bin.tar.gz",
|
||||
"opencloudConfig": "tests/config/woodpecker/opencloud-config.json",
|
||||
"opencloudRevaDataRoot": "/woodpecker/src/github.com/%s/srv/app/tmp/ocis/owncloud/data" % repo_slug,
|
||||
"multiServiceOcBaseDataPath": "/woodpecker/src/github.com/%s/multiServiceData" % repo_slug,
|
||||
"ocWrapper": "/woodpecker/src/github.com/%s/tests/ocwrapper" % repo_slug,
|
||||
"opencloudRevaDataRoot": "/woodpecker/src/github.com/opencloud-eu/opencloud/srv/app/tmp/ocis/owncloud/data",
|
||||
"multiServiceOcBaseDataPath": "/woodpecker/src/github.com/opencloud-eu/opencloud/multiServiceData",
|
||||
"ocWrapper": "/woodpecker/src/github.com/opencloud-eu/opencloud/tests/ocwrapper",
|
||||
"bannedPasswordList": "tests/config/woodpecker/banned-password-list.txt",
|
||||
"ocmProviders": "tests/config/woodpecker/providers.json",
|
||||
"opencloudBinPath": "opencloud/bin",
|
||||
@@ -137,8 +137,7 @@ config = {
|
||||
"suites": [
|
||||
"apiGraph",
|
||||
"apiServiceAvailability",
|
||||
# skip tests for collaborativePosix. see https://github.com/opencloud-eu/opencloud/issues/2036
|
||||
#"collaborativePosix",
|
||||
"collaborativePosix",
|
||||
],
|
||||
"skip": False,
|
||||
"withRemotePhp": [True],
|
||||
@@ -389,8 +388,6 @@ config = {
|
||||
"production": {
|
||||
# NOTE: need to be updated if new production releases are determined
|
||||
"tags": ["2.0", "4.0"],
|
||||
# NOTE: need to be set to true if patch releases are made from stable-X-branches
|
||||
"skip_rolling": "false",
|
||||
"repo": docker_repo_slug,
|
||||
"build_type": "production",
|
||||
},
|
||||
@@ -414,7 +411,7 @@ GRAPH_AVAILABLE_ROLES = "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5,a8d5fe5e-96e3-418d
|
||||
workspace = \
|
||||
{
|
||||
"base": "/go",
|
||||
"path": "src/github.com/%s/" % repo_slug,
|
||||
"path": "src/github.com/opencloud-eu/opencloud/",
|
||||
}
|
||||
|
||||
# minio mc environment variables
|
||||
@@ -482,10 +479,6 @@ def main(ctx):
|
||||
if ctx.build.event == "cron" and ctx.build.sender == "translation-sync":
|
||||
return translation_sync(ctx)
|
||||
|
||||
is_release_pr = (ctx.build.event == "pull_request" and ctx.build.sender == "openclouders" and "🎉 release" in ctx.build.title.lower())
|
||||
if is_release_pr:
|
||||
return [licenseCheck(ctx)]
|
||||
|
||||
build_release_helpers = \
|
||||
readyReleaseGo()
|
||||
|
||||
@@ -556,6 +549,7 @@ def main(ctx):
|
||||
def cachePipeline(ctx, name, steps):
|
||||
return {
|
||||
"name": "build-%s-cache" % name,
|
||||
"skip_clone": True,
|
||||
"steps": steps,
|
||||
"when": [
|
||||
{
|
||||
@@ -1231,7 +1225,7 @@ def wopiValidatorTests(ctx, storage, wopiServerType, accounts_hash_difficulty =
|
||||
"commands": [
|
||||
"curl -v -X PUT '%s/remote.php/webdav/test.wopitest' -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin -D headers.txt" % OC_URL,
|
||||
"cat headers.txt",
|
||||
"export FILE_ID=$(cat headers.txt | sed -n -e 's/^.*oc-fileid: //Ip')",
|
||||
"export FILE_ID=$(cat headers.txt | sed -n -e 's/^.*Oc-Fileid: //p')",
|
||||
"export URL=\"%s/app/open?app_name=FakeOffice&file_id=$FILE_ID\"" % OC_URL,
|
||||
"export URL=$(echo $URL | tr -d '[:cntrl:]')",
|
||||
"curl -v -X POST \"$URL\" -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin > open.json",
|
||||
@@ -1614,40 +1608,31 @@ def uploadTracingResult(ctx):
|
||||
|
||||
def dockerReleases(ctx):
|
||||
pipelines = []
|
||||
docker_releases = []
|
||||
docker_repos = []
|
||||
build_type = ""
|
||||
|
||||
# only make realeases on tag events
|
||||
if ctx.build.event == "tag":
|
||||
tag = ctx.build.ref.replace("refs/tags/v", "").lower()
|
||||
|
||||
# iterate over production tags to see if this is a production release
|
||||
is_production = False
|
||||
skip_rolling = False
|
||||
for prod_tag in config["dockerReleases"]["production"]["tags"]:
|
||||
if tag.startswith(prod_tag):
|
||||
is_production = True
|
||||
skip_rolling = config["dockerReleases"]["production"]["skip_rolling"]
|
||||
break
|
||||
|
||||
if is_production:
|
||||
docker_releases.append("production")
|
||||
|
||||
# a new production realease is also a rolling release
|
||||
# unless skip_rolling is set in the config, i.e. for patch-releases on stable-branch
|
||||
if not skip_rolling:
|
||||
docker_releases.append("rolling")
|
||||
docker_repos.append(config["dockerReleases"]["production"]["repo"])
|
||||
build_type = config["dockerReleases"]["production"]["build_type"]
|
||||
|
||||
else:
|
||||
docker_releases.append("rolling")
|
||||
docker_repos.append(config["dockerReleases"]["rolling"]["repo"])
|
||||
build_type = config["dockerReleases"]["rolling"]["build_type"]
|
||||
|
||||
# on non tag events, do daily build
|
||||
else:
|
||||
docker_releases.append("daily")
|
||||
docker_repos.append(config["dockerReleases"]["daily"]["repo"])
|
||||
build_type = config["dockerReleases"]["daily"]["build_type"]
|
||||
|
||||
for releaseConfigName in docker_releases:
|
||||
repo = config["dockerReleases"][releaseConfigName]["repo"]
|
||||
build_type = config["dockerReleases"][releaseConfigName]["build_type"]
|
||||
for repo in docker_repos:
|
||||
repo_pipelines = []
|
||||
repo_pipelines.append(dockerRelease(ctx, repo, build_type))
|
||||
|
||||
@@ -1667,7 +1652,6 @@ def dockerRelease(ctx, repo, build_type):
|
||||
build_args = {
|
||||
"REVISION": "%s" % ctx.build.commit,
|
||||
"VERSION": "%s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "daily"),
|
||||
"EDITION": "stable" if build_type == "production" else "rolling",
|
||||
}
|
||||
|
||||
# if no additional tag is given, the build-plugin adds latest
|
||||
@@ -1831,7 +1815,6 @@ def binaryRelease(ctx, arch, depends_on = []):
|
||||
"image": OC_CI_GOLANG,
|
||||
"environment": {
|
||||
"VERSION": (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "daily"),
|
||||
"EDITION": "rolling",
|
||||
"HTTP_PROXY": {
|
||||
"from_secret": "ci_http_proxy",
|
||||
},
|
||||
@@ -2357,12 +2340,11 @@ def translation_sync(ctx):
|
||||
"image": OC_CI_GOLANG,
|
||||
"commands": [
|
||||
"make l10n-read",
|
||||
"mkdir tx && cd tx",
|
||||
"curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash",
|
||||
"export PATH=$PATH:$(pwd) && cd ..",
|
||||
". ~/.profile",
|
||||
"make l10n-push",
|
||||
"make l10n-pull",
|
||||
"rm -rf tx",
|
||||
"rm tx",
|
||||
"make l10n-clean",
|
||||
],
|
||||
"environment": {
|
||||
@@ -2499,7 +2481,7 @@ def genericBuildArtifactCache(ctx, name, action, path):
|
||||
return genericCache(name, action, [path], cache_path)
|
||||
|
||||
if action == "purge":
|
||||
return purgeCache("purge_opencloud_build_artifact_cache", "cache/%s" % repo_slug, 1)
|
||||
return purgeCache("purge_opencloud_build_artifact_cache", "cache/opencloud-eu/opencloud", 1)
|
||||
return []
|
||||
|
||||
def restoreBuildArtifactCache(ctx, name, path):
|
||||
@@ -2705,13 +2687,15 @@ def setupForLitmus():
|
||||
}]
|
||||
|
||||
def getWoodpeckerEnvAndCheckScript(ctx):
|
||||
path_to_woodpecker_env = "%s/.woodpecker.env" % dirs["base"]
|
||||
path_to_check_script = "%s/tests/config/woodpecker/check_web_cache.sh" % dirs["base"]
|
||||
opencloud_git_base_url = "https://raw.githubusercontent.com/opencloud-eu/opencloud"
|
||||
path_to_woodpecker_env = "%s/%s/.woodpecker.env" % (opencloud_git_base_url, ctx.build.commit)
|
||||
path_to_check_script = "%s/%s/tests/config/woodpecker/check_web_cache.sh" % (opencloud_git_base_url, ctx.build.commit)
|
||||
return {
|
||||
"name": "get-woodpecker-env-and-check-script",
|
||||
"image": OC_UBUNTU,
|
||||
"commands": [
|
||||
"cp %s check_web_cache.sh" % path_to_check_script,
|
||||
"curl -s -o .woodpecker.env %s" % path_to_woodpecker_env,
|
||||
"curl -s -o check_web_cache.sh %s" % path_to_check_script,
|
||||
],
|
||||
}
|
||||
|
||||
@@ -2945,7 +2929,7 @@ def restoreBrowsersCache():
|
||||
"name": "unzip-browsers-cache",
|
||||
"image": OC_UBUNTU,
|
||||
"commands": [
|
||||
"tar -xf /woodpecker/src/github.com/%s/webTestRunner/playwright-browsers.tar.gz -C ." % repo_slug,
|
||||
"tar -xf /woodpecker/src/github.com/opencloud-eu/opencloud/webTestRunner/playwright-browsers.tar.gz -C .",
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -3133,7 +3117,7 @@ def k6LoadTests(ctx):
|
||||
if "skip" in config["k6LoadTests"] and config["k6LoadTests"]["skip"]:
|
||||
return []
|
||||
|
||||
opencloud_git_base_url = "https://raw.githubusercontent.com/%s" % repo_slug
|
||||
opencloud_git_base_url = "https://raw.githubusercontent.com/opencloud-eu/opencloud"
|
||||
script_link = "%s/%s/tests/config/woodpecker/run_k6_tests.sh" % (opencloud_git_base_url, ctx.build.commit)
|
||||
|
||||
event_array = ["cron"]
|
||||
|
||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,41 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [4.1.0](https://github.com/opencloud-eu/opencloud/releases/tag/v4.1.0) - 2025-12-15
|
||||
|
||||
### ❤️ Thanks to all contributors! ❤️
|
||||
|
||||
@JammingBen, @ScharfViktor, @Svanvith, @butonic, @flimmy, @fschade, @individual-it, @kulmann, @micbar, @prashant-gurung899, @saw-jan
|
||||
|
||||
### 📚 Documentation
|
||||
|
||||
- fix typo [[#2024](https://github.com/opencloud-eu/opencloud/pull/2024)]
|
||||
- [docs] update policies link [[#1996](https://github.com/opencloud-eu/opencloud/pull/1996)]
|
||||
- fix the link in quickstart script for itself [[#1956](https://github.com/opencloud-eu/opencloud/pull/1956)]
|
||||
|
||||
### ✅ Tests
|
||||
|
||||
- [full-ci][tests-only] test: fix some test flakiness [[#2003](https://github.com/opencloud-eu/opencloud/pull/2003)]
|
||||
- [tests-only] Skip test related pipelines for ready-release-go PRs [[#2011](https://github.com/opencloud-eu/opencloud/pull/2011)]
|
||||
- [full-ci][tests-only] test: add test to check mismatch offset during TUS upload [[#1993](https://github.com/opencloud-eu/opencloud/pull/1993)]
|
||||
- [full-ci][tests-only] test: proper resource existence check [[#1990](https://github.com/opencloud-eu/opencloud/pull/1990)]
|
||||
- check propfing after renaming data in file system [[#1809](https://github.com/opencloud-eu/opencloud/pull/1809)]
|
||||
- fix-get-attribute-test [[#1974](https://github.com/opencloud-eu/opencloud/pull/1974)]
|
||||
|
||||
### 📈 Enhancement
|
||||
|
||||
- Show edition in opencloud version command [[#2019](https://github.com/opencloud-eu/opencloud/pull/2019)]
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- fix: enforce trailing slash for server url [[#1995](https://github.com/opencloud-eu/opencloud/pull/1995)]
|
||||
- fix: enhance resource creation with detailed process information [[#1978](https://github.com/opencloud-eu/opencloud/pull/1978)]
|
||||
|
||||
### 📦️ Dependencies
|
||||
|
||||
- chore: bump web to v4.3.0 [[#2030](https://github.com/opencloud-eu/opencloud/pull/2030)]
|
||||
- reva-bump-2.41.0 [[#2032](https://github.com/opencloud-eu/opencloud/pull/2032)]
|
||||
- build(deps): bump github.com/testcontainers/testcontainers-go from 0.39.0 to 0.40.0 [[#1931](https://github.com/opencloud-eu/opencloud/pull/1931)]
|
||||
|
||||
## [4.0.0](https://github.com/opencloud-eu/opencloud/releases/tag/v4.0.0) - 2025-12-01
|
||||
|
||||
### ❤️ Thanks to all contributors! ❤️
|
||||
|
||||
6
Makefile
6
Makefile
@@ -27,6 +27,7 @@ OC_MODULES = \
|
||||
services/app-provider \
|
||||
services/app-registry \
|
||||
services/audit \
|
||||
services/auth-api \
|
||||
services/auth-app \
|
||||
services/auth-basic \
|
||||
services/auth-bearer \
|
||||
@@ -39,6 +40,7 @@ OC_MODULES = \
|
||||
services/gateway \
|
||||
services/graph \
|
||||
services/groups \
|
||||
services/groupware \
|
||||
services/idm \
|
||||
services/idp \
|
||||
services/invitations \
|
||||
@@ -198,10 +200,6 @@ go-mod-tidy:
|
||||
test:
|
||||
@go test -v -tags '$(TAGS)' -coverprofile coverage.out ./...
|
||||
|
||||
.PHONY: test-with-race
|
||||
test-with-race:
|
||||
@go test -race -v -tags '$(TAGS)' -coverprofile coverage.out ./...
|
||||
|
||||
.PHONY: go-coverage
|
||||
go-coverage:
|
||||
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
|
||||
|
||||
@@ -305,8 +305,15 @@ KEYCLOAK_ADMIN_PASSWORD=
|
||||
# Leaving it default stores data in docker internal volumes.
|
||||
#RADICALE_DATA_DIR=/your/local/radicale/data
|
||||
|
||||
### Stalwart Settings ###
|
||||
# Note: the leading colon is required to enable the service.
|
||||
#STALWART=:stalwart.yml
|
||||
# Domain of Stalwart
|
||||
# Defaults to "stalwart.opencloud.test"
|
||||
STALWART_DOMAIN=
|
||||
|
||||
## IMPORTANT ##
|
||||
# This MUST be the last line as it assembles the supplemental compose files to be used.
|
||||
# ALL supplemental configs must be added here, whether commented or not.
|
||||
# Each var must either be empty or contain :path/file.yml
|
||||
COMPOSE_FILE=docker-compose.yml${OPENCLOUD:-}${TIKA:-}${DECOMPOSEDS3:-}${DECOMPOSEDS3_MINIO:-}${DECOMPOSED:-}${COLLABORA:-}${MONITORING:-}${IMPORTER:-}${CLAMAV:-}${INBUCKET:-}${EXTENSIONS:-}${UNZIP:-}${DRAWIO:-}${JSONVIEWER:-}${PROGRESSBARS:-}${EXTERNALSITES:-}${KEYCLOAK:-}${LDAP:-}${KEYCLOAK_AUTOPROVISIONING:-}${LDAP_MANAGER:-}${RADICALE:-}
|
||||
COMPOSE_FILE=docker-compose.yml${OPENCLOUD:-}${TIKA:-}${DECOMPOSEDS3:-}${DECOMPOSEDS3_MINIO:-}${DECOMPOSED:-}${COLLABORA:-}${MONITORING:-}${IMPORTER:-}${CLAMAV:-}${INBUCKET:-}${EXTENSIONS:-}${UNZIP:-}${DRAWIO:-}${JSONVIEWER:-}${PROGRESSBARS:-}${EXTERNALSITES:-}${KEYCLOAK:-}${LDAP:-}${KEYCLOAK_AUTOPROVISIONING:-}${LDAP_MANAGER:-}${RADICALE:-}${STALWART:-}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"clientId": "groupware",
|
||||
"name": "OpenCloud Groupware",
|
||||
"description": "Used for authenticating automated HTTP clients of the OpenCloud Groupware API",
|
||||
"rootUrl": "",
|
||||
"adminUrl": "",
|
||||
"baseUrl": "",
|
||||
"surrogateAuthRequired": false,
|
||||
"enabled": true,
|
||||
"alwaysDisplayInConsole": false,
|
||||
"clientAuthenticatorType": "client-secret",
|
||||
"redirectUris": [
|
||||
"/*"
|
||||
],
|
||||
"webOrigins": [
|
||||
"/*"
|
||||
],
|
||||
"notBefore": 0,
|
||||
"bearerOnly": false,
|
||||
"consentRequired": false,
|
||||
"standardFlowEnabled": true,
|
||||
"implicitFlowEnabled": false,
|
||||
"directAccessGrantsEnabled": true,
|
||||
"serviceAccountsEnabled": false,
|
||||
"publicClient": true,
|
||||
"frontchannelLogout": true,
|
||||
"protocol": "openid-connect",
|
||||
"attributes": {
|
||||
"oidc.ciba.grant.enabled": "false",
|
||||
"backchannel.logout.session.required": "true",
|
||||
"oauth2.device.authorization.grant.enabled": "false",
|
||||
"backchannel.logout.revoke.offline.tokens": "false"
|
||||
},
|
||||
"authenticationFlowBindingOverrides": {},
|
||||
"fullScopeAllowed": true,
|
||||
"nodeReRegistrationTimeout": -1,
|
||||
"defaultClientScopes": [
|
||||
"web-origins",
|
||||
"acr",
|
||||
"profile",
|
||||
"roles",
|
||||
"groups",
|
||||
"OpenCloudUnique_ID",
|
||||
"basic",
|
||||
"email"
|
||||
],
|
||||
"optionalClientScopes": [
|
||||
"address",
|
||||
"phone",
|
||||
"offline_access",
|
||||
"microprofile-jwt"
|
||||
],
|
||||
"access": {
|
||||
"view": true,
|
||||
"configure": true,
|
||||
"manage": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
dn: ou=policies,dc=opencloud,dc=eu
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: policies
|
||||
|
||||
dn: cn=default,ou=policies,dc=opencloud,dc=eu
|
||||
cn: default
|
||||
objectClass: pwdPolicy
|
||||
objectClass: person
|
||||
objectClass: top
|
||||
pwdAllowUserChange: TRUE
|
||||
pwdAttribute: userPassword
|
||||
pwdCheckQuality: 0
|
||||
pwdExpireWarning: 600
|
||||
pwdFailureCountInterval: 30
|
||||
pwdGraceAuthNLimit: 5
|
||||
pwdInHistory: 5
|
||||
pwdLockout: FALSE
|
||||
pwdLockoutDuration: 0
|
||||
pwdMaxAge: 0
|
||||
pwdMaxFailure: 5
|
||||
pwdMinAge: 0
|
||||
pwdMinLength: 1
|
||||
pwdMustChange: FALSE
|
||||
pwdSafeModify: FALSE
|
||||
sn: default
|
||||
@@ -0,0 +1,21 @@
|
||||
# Stalwart Configuration
|
||||
|
||||
The mechanics are currently to mount a different configuration file depending on the environment, as we support two scenarios that are described in [`services/groupware/DEVELOPER.md`](../../../../../services/groupware/DEVELOPER.md):
|
||||
|
||||
* «production» setup, with OpenLDAP and Keycloak containers
|
||||
* «homelab» setup, with the built-in IDM (LDAP) and IDP that run as part of the `opencloud` container
|
||||
|
||||
The Docker Compose setup (in [`stalwart.yml`](../../stalwart.yml)) mounts either [`idmldap.toml`](./idmldap.toml) or [`ldap.toml`](./ldap.toml) depending on how the variable `STALWART_AUTH_DIRECTORY` is set, which is either `idmldap` for the homelab setup, or `ldap` for the production setup.
|
||||
|
||||
This is thus all done automatically, but whenever changes are performed to Stalwart configuration files, they must be reflected across those two files, to keep them in sync, as the only entry that should differ is this one:
|
||||
|
||||
```ruby
|
||||
storage.directory = "ldap"
|
||||
```
|
||||
|
||||
or this:
|
||||
|
||||
```ruby
|
||||
storage.directory = "idmldap"
|
||||
```
|
||||
|
||||
110
devtools/deployments/opencloud_full/config/stalwart/config.toml
Normal file
110
devtools/deployments/opencloud_full/config/stalwart/config.toml
Normal file
@@ -0,0 +1,110 @@
|
||||
authentication.fallback-admin.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.fallback-admin.user = "mailadmin"
|
||||
authentication.master.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.master.user = "master"
|
||||
directory.idmldap.attributes.class = "objectClass"
|
||||
directory.idmldap.attributes.description = "displayName"
|
||||
directory.idmldap.attributes.email = "mail"
|
||||
directory.idmldap.attributes.groups = "memberOf"
|
||||
directory.idmldap.attributes.name = "uid"
|
||||
directory.idmldap.attributes.secret = "userPassword"
|
||||
directory.idmldap.base-dn = "o=libregraph-idm"
|
||||
directory.idmldap.bind.auth.method = "default"
|
||||
directory.idmldap.bind.dn = "uid=reva,ou=sysusers,o=libregraph-idm"
|
||||
directory.idmldap.bind.secret = "admin"
|
||||
directory.idmldap.cache.size = 1048576
|
||||
directory.idmldap.cache.ttl.negative = "10m"
|
||||
directory.idmldap.cache.ttl.positive = "1h"
|
||||
directory.idmldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(mail=?))"
|
||||
directory.idmldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(uid=?))"
|
||||
directory.idmldap.timeout = "15s"
|
||||
directory.idmldap.tls.allow-invalid-certs = true
|
||||
directory.idmldap.tls.enable = true
|
||||
directory.idmldap.type = "ldap"
|
||||
directory.idmldap.url = "ldaps://opencloud:9235"
|
||||
directory.keycloak.auth.method = "user-token"
|
||||
directory.keycloak.cache.size = 1048576
|
||||
directory.keycloak.cache.ttl.negative = "10m"
|
||||
directory.keycloak.cache.ttl.positive = "1h"
|
||||
directory.keycloak.endpoint.method = "introspect"
|
||||
directory.keycloak.endpoint.url = "http://keycloak:8080/realms/openCloud/protocol/openid-connect/userinfo"
|
||||
directory.keycloak.fields.email = "email"
|
||||
directory.keycloak.fields.full-name = "name"
|
||||
directory.keycloak.fields.username = "preferred_username"
|
||||
directory.keycloak.timeout = "15s"
|
||||
directory.keycloak.type = "oidc"
|
||||
directory.ldap.attributes.class = "objectClass"
|
||||
directory.ldap.attributes.description = "displayName"
|
||||
directory.ldap.attributes.email = "mail"
|
||||
directory.ldap.attributes.email-alias = "mailAlias"
|
||||
directory.ldap.attributes.groups = "memberOf"
|
||||
directory.ldap.attributes.name = "uid"
|
||||
directory.ldap.attributes.secret = "userPassword"
|
||||
directory.ldap.attributes.secret-changed = "pwdChangedTime"
|
||||
directory.ldap.base-dn = "dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.dn = "cn=?,ou=users,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.enable = true
|
||||
directory.ldap.bind.auth.search = true
|
||||
directory.ldap.bind.dn = "cn=admin,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.secret = "admin"
|
||||
directory.ldap.cache.ttl.negative = "10m"
|
||||
directory.ldap.cache.ttl.positive = "1h"
|
||||
directory.ldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(mail=?)(mailAlias=?)(cn=?)))"
|
||||
directory.ldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(cn=?)))"
|
||||
directory.ldap.timeout = "5s"
|
||||
directory.ldap.tls.allow-invalid-certs = true
|
||||
directory.ldap.tls.enable = true
|
||||
directory.ldap.type = "ldap"
|
||||
directory.ldap.url = "ldap://ldap-server:1389"
|
||||
http.allowed-endpoint = 200
|
||||
http.hsts = true
|
||||
http.permissive-cors = false
|
||||
http.url = "'https://' + config_get('server.hostname')"
|
||||
http.use-x-forwarded = true
|
||||
metrics.prometheus.auth.secret = "secret"
|
||||
metrics.prometheus.auth.username = "metrics"
|
||||
metrics.prometheus.enable = true
|
||||
server.listener.http.bind = "0.0.0.0:8080"
|
||||
server.listener.http.protocol = "http"
|
||||
server.listener.https.bind = "0.0.0.0:443"
|
||||
server.listener.https.protocol = "http"
|
||||
server.listener.https.tls.implicit = true
|
||||
server.listener.imap.bind = "0.0.0.0:143"
|
||||
server.listener.imap.protocol = "imap"
|
||||
server.listener.imaptls.bind = "0.0.0.0:993"
|
||||
server.listener.imaptls.protocol = "imap"
|
||||
server.listener.imaptls.tls.implicit = true
|
||||
server.listener.pop3.bind = "0.0.0.0:110"
|
||||
server.listener.pop3.protocol = "pop3"
|
||||
server.listener.pop3s.bind = "0.0.0.0:995"
|
||||
server.listener.pop3s.protocol = "pop3"
|
||||
server.listener.pop3s.tls.implicit = true
|
||||
server.listener.sieve.bind = "0.0.0.0:4190"
|
||||
server.listener.sieve.protocol = "managesieve"
|
||||
server.listener.smtp.bind = "0.0.0.0:25"
|
||||
server.listener.smtp.protocol = "smtp"
|
||||
server.listener.submission.bind = "0.0.0.0:587"
|
||||
server.listener.submission.protocol = "smtp"
|
||||
server.listener.submissions.bind = "0.0.0.0:465"
|
||||
server.listener.submissions.protocol = "smtp"
|
||||
server.listener.submissions.tls.implicit = true
|
||||
server.max-connections = 8192
|
||||
server.socket.backlog = 1024
|
||||
server.socket.nodelay = true
|
||||
server.socket.reuse-addr = true
|
||||
server.socket.reuse-port = true
|
||||
storage.blob = "rocksdb"
|
||||
storage.data = "rocksdb"
|
||||
storage.directory = "%{env:STALWART_AUTH_DIRECTORY}%"
|
||||
storage.fts = "rocksdb"
|
||||
storage.lookup = "rocksdb"
|
||||
store.rocksdb.compression = "lz4"
|
||||
store.rocksdb.path = "/opt/stalwart/data"
|
||||
store.rocksdb.type = "rocksdb"
|
||||
tracer.console.ansi = true
|
||||
tracer.console.buffered = true
|
||||
tracer.console.enable = true
|
||||
tracer.console.level = "trace"
|
||||
tracer.console.lossy = false
|
||||
tracer.console.multiline = false
|
||||
tracer.console.type = "stdout"
|
||||
111
devtools/deployments/opencloud_full/config/stalwart/idmldap.toml
Normal file
111
devtools/deployments/opencloud_full/config/stalwart/idmldap.toml
Normal file
@@ -0,0 +1,111 @@
|
||||
authentication.fallback-admin.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.fallback-admin.user = "mailadmin"
|
||||
authentication.master.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.master.user = "master"
|
||||
directory.idmldap.attributes.class = "objectClass"
|
||||
directory.idmldap.attributes.description = "displayName"
|
||||
directory.idmldap.attributes.email = "mail"
|
||||
directory.idmldap.attributes.groups = "memberOf"
|
||||
directory.idmldap.attributes.name = "cn"
|
||||
directory.idmldap.attributes.secret = "userPassword"
|
||||
directory.idmldap.base-dn = "o=libregraph-idm"
|
||||
directory.idmldap.bind.auth.method = "default"
|
||||
directory.idmldap.bind.dn = "uid=reva,ou=sysusers,o=libregraph-idm"
|
||||
directory.idmldap.bind.secret = "admin"
|
||||
directory.idmldap.cache.size = 1048576
|
||||
directory.idmldap.cache.ttl.negative = "10m"
|
||||
directory.idmldap.cache.ttl.positive = "1h"
|
||||
directory.idmldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(mail=?))"
|
||||
directory.idmldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(cn=?))"
|
||||
directory.idmldap.timeout = "15s"
|
||||
directory.idmldap.tls.allow-invalid-certs = true
|
||||
directory.idmldap.tls.enable = true
|
||||
directory.idmldap.type = "ldap"
|
||||
directory.idmldap.url = "ldaps://opencloud:9235"
|
||||
directory.keycloak.auth.method = "user-token"
|
||||
directory.keycloak.cache.size = 1048576
|
||||
directory.keycloak.cache.ttl.negative = "10m"
|
||||
directory.keycloak.cache.ttl.positive = "1h"
|
||||
directory.keycloak.endpoint.method = "introspect"
|
||||
directory.keycloak.endpoint.url = "http://keycloak:8080/realms/openCloud/protocol/openid-connect/userinfo"
|
||||
directory.keycloak.fields.email = "email"
|
||||
directory.keycloak.fields.full-name = "name"
|
||||
directory.keycloak.fields.username = "preferred_username"
|
||||
directory.keycloak.timeout = "15s"
|
||||
directory.keycloak.type = "oidc"
|
||||
directory.ldap.attributes.class = "objectClass"
|
||||
directory.ldap.attributes.description = "displayName"
|
||||
directory.ldap.attributes.email = "mail"
|
||||
directory.ldap.attributes.email-alias = "mailAlias"
|
||||
directory.ldap.attributes.groups = "memberOf"
|
||||
directory.ldap.attributes.name = "uid"
|
||||
directory.ldap.attributes.secret = "userPassword"
|
||||
directory.ldap.attributes.secret-changed = "pwdChangedTime"
|
||||
directory.ldap.base-dn = "dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.dn = "cn=?,ou=users,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.enable = true
|
||||
directory.ldap.bind.auth.search = true
|
||||
directory.ldap.bind.dn = "cn=admin,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.secret = "admin"
|
||||
directory.ldap.cache.ttl.negative = "10m"
|
||||
directory.ldap.cache.ttl.positive = "1h"
|
||||
directory.ldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(mail=?)(mailAlias=?)(cn=?)))"
|
||||
directory.ldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(cn=?)))"
|
||||
directory.ldap.timeout = "5s"
|
||||
directory.ldap.tls.allow-invalid-certs = true
|
||||
directory.ldap.tls.enable = true
|
||||
directory.ldap.type = "ldap"
|
||||
directory.ldap.url = "ldap://ldap-server:1389"
|
||||
http.allowed-endpoint = 200
|
||||
http.hsts = true
|
||||
http.permissive-cors = false
|
||||
http.url = "'https://' + config_get('server.hostname')"
|
||||
http.use-x-forwarded = true
|
||||
metrics.prometheus.auth.secret = "secret"
|
||||
metrics.prometheus.auth.username = "metrics"
|
||||
metrics.prometheus.enable = true
|
||||
server.listener.http.bind = "0.0.0.0:8080"
|
||||
server.listener.http.protocol = "http"
|
||||
server.listener.https.bind = "0.0.0.0:443"
|
||||
server.listener.https.protocol = "http"
|
||||
server.listener.https.tls.implicit = true
|
||||
server.listener.imap.bind = "0.0.0.0:143"
|
||||
server.listener.imap.protocol = "imap"
|
||||
server.listener.imaptls.bind = "0.0.0.0:993"
|
||||
server.listener.imaptls.protocol = "imap"
|
||||
server.listener.imaptls.tls.implicit = true
|
||||
server.listener.pop3.bind = "0.0.0.0:110"
|
||||
server.listener.pop3.protocol = "pop3"
|
||||
server.listener.pop3s.bind = "0.0.0.0:995"
|
||||
server.listener.pop3s.protocol = "pop3"
|
||||
server.listener.pop3s.tls.implicit = true
|
||||
server.listener.sieve.bind = "0.0.0.0:4190"
|
||||
server.listener.sieve.protocol = "managesieve"
|
||||
server.listener.smtp.bind = "0.0.0.0:25"
|
||||
server.listener.smtp.protocol = "smtp"
|
||||
server.listener.submission.bind = "0.0.0.0:587"
|
||||
server.listener.submission.protocol = "smtp"
|
||||
server.listener.submissions.bind = "0.0.0.0:465"
|
||||
server.listener.submissions.protocol = "smtp"
|
||||
server.listener.submissions.tls.implicit = true
|
||||
server.max-connections = 8192
|
||||
server.socket.backlog = 1024
|
||||
server.socket.nodelay = true
|
||||
server.socket.reuse-addr = true
|
||||
server.socket.reuse-port = true
|
||||
storage.blob = "rocksdb"
|
||||
storage.data = "rocksdb"
|
||||
storage.directory = "idmldap"
|
||||
storage.fts = "rocksdb"
|
||||
storage.lookup = "rocksdb"
|
||||
store.rocksdb.compression = "lz4"
|
||||
store.rocksdb.path = "/opt/stalwart/data"
|
||||
store.rocksdb.type = "rocksdb"
|
||||
tracer.console.ansi = true
|
||||
tracer.console.buffered = true
|
||||
tracer.console.enable = true
|
||||
tracer.console.level = "trace"
|
||||
tracer.console.lossy = false
|
||||
tracer.console.multiline = false
|
||||
tracer.console.type = "stdout"
|
||||
sharing.allow-directory-query = false
|
||||
110
devtools/deployments/opencloud_full/config/stalwart/ldap.toml
Normal file
110
devtools/deployments/opencloud_full/config/stalwart/ldap.toml
Normal file
@@ -0,0 +1,110 @@
|
||||
authentication.fallback-admin.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.fallback-admin.user = "mailadmin"
|
||||
authentication.master.secret = "$6$4qPYDVhaUHkKcY7s$bB6qhcukb9oFNYRIvaDZgbwxrMa2RvF5dumCjkBFdX19lSNqrgKltf3aPrFMuQQKkZpK2YNuQ83hB1B3NiWzj."
|
||||
authentication.master.user = "master"
|
||||
directory.idmldap.attributes.class = "objectClass"
|
||||
directory.idmldap.attributes.description = "displayName"
|
||||
directory.idmldap.attributes.email = "mail"
|
||||
directory.idmldap.attributes.groups = "memberOf"
|
||||
directory.idmldap.attributes.name = "uid"
|
||||
directory.idmldap.attributes.secret = "userPassword"
|
||||
directory.idmldap.base-dn = "o=libregraph-idm"
|
||||
directory.idmldap.bind.auth.method = "default"
|
||||
directory.idmldap.bind.dn = "uid=reva,ou=sysusers,o=libregraph-idm"
|
||||
directory.idmldap.bind.secret = "admin"
|
||||
directory.idmldap.cache.size = 1048576
|
||||
directory.idmldap.cache.ttl.negative = "10m"
|
||||
directory.idmldap.cache.ttl.positive = "1h"
|
||||
directory.idmldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(mail=?))"
|
||||
directory.idmldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(uid=?))"
|
||||
directory.idmldap.timeout = "15s"
|
||||
directory.idmldap.tls.allow-invalid-certs = true
|
||||
directory.idmldap.tls.enable = true
|
||||
directory.idmldap.type = "ldap"
|
||||
directory.idmldap.url = "ldaps://opencloud:9235"
|
||||
directory.keycloak.auth.method = "user-token"
|
||||
directory.keycloak.cache.size = 1048576
|
||||
directory.keycloak.cache.ttl.negative = "10m"
|
||||
directory.keycloak.cache.ttl.positive = "1h"
|
||||
directory.keycloak.endpoint.method = "introspect"
|
||||
directory.keycloak.endpoint.url = "http://keycloak:8080/realms/openCloud/protocol/openid-connect/userinfo"
|
||||
directory.keycloak.fields.email = "email"
|
||||
directory.keycloak.fields.full-name = "name"
|
||||
directory.keycloak.fields.username = "preferred_username"
|
||||
directory.keycloak.timeout = "15s"
|
||||
directory.keycloak.type = "oidc"
|
||||
directory.ldap.attributes.class = "objectClass"
|
||||
directory.ldap.attributes.description = "displayName"
|
||||
directory.ldap.attributes.email = "mail"
|
||||
directory.ldap.attributes.email-alias = "mailAlias"
|
||||
directory.ldap.attributes.groups = "memberOf"
|
||||
directory.ldap.attributes.name = "uid"
|
||||
directory.ldap.attributes.secret = "userPassword"
|
||||
directory.ldap.attributes.secret-changed = "pwdChangedTime"
|
||||
directory.ldap.base-dn = "dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.dn = "cn=?,ou=users,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.auth.enable = true
|
||||
directory.ldap.bind.auth.search = true
|
||||
directory.ldap.bind.dn = "cn=admin,dc=opencloud,dc=eu"
|
||||
directory.ldap.bind.secret = "admin"
|
||||
directory.ldap.cache.ttl.negative = "10m"
|
||||
directory.ldap.cache.ttl.positive = "1h"
|
||||
directory.ldap.filter.email = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(mail=?)(mailAlias=?)(cn=?)))"
|
||||
directory.ldap.filter.name = "(&(|(objectClass=person)(objectClass=groupOfNames))(|(uid=?)(cn=?)))"
|
||||
directory.ldap.timeout = "5s"
|
||||
directory.ldap.tls.allow-invalid-certs = true
|
||||
directory.ldap.tls.enable = true
|
||||
directory.ldap.type = "ldap"
|
||||
directory.ldap.url = "ldap://ldap-server:1389"
|
||||
http.allowed-endpoint = 200
|
||||
http.hsts = true
|
||||
http.permissive-cors = false
|
||||
http.url = "'https://' + config_get('server.hostname')"
|
||||
http.use-x-forwarded = true
|
||||
metrics.prometheus.auth.secret = "secret"
|
||||
metrics.prometheus.auth.username = "metrics"
|
||||
metrics.prometheus.enable = true
|
||||
server.listener.http.bind = "0.0.0.0:8080"
|
||||
server.listener.http.protocol = "http"
|
||||
server.listener.https.bind = "0.0.0.0:443"
|
||||
server.listener.https.protocol = "http"
|
||||
server.listener.https.tls.implicit = true
|
||||
server.listener.imap.bind = "0.0.0.0:143"
|
||||
server.listener.imap.protocol = "imap"
|
||||
server.listener.imaptls.bind = "0.0.0.0:993"
|
||||
server.listener.imaptls.protocol = "imap"
|
||||
server.listener.imaptls.tls.implicit = true
|
||||
server.listener.pop3.bind = "0.0.0.0:110"
|
||||
server.listener.pop3.protocol = "pop3"
|
||||
server.listener.pop3s.bind = "0.0.0.0:995"
|
||||
server.listener.pop3s.protocol = "pop3"
|
||||
server.listener.pop3s.tls.implicit = true
|
||||
server.listener.sieve.bind = "0.0.0.0:4190"
|
||||
server.listener.sieve.protocol = "managesieve"
|
||||
server.listener.smtp.bind = "0.0.0.0:25"
|
||||
server.listener.smtp.protocol = "smtp"
|
||||
server.listener.submission.bind = "0.0.0.0:587"
|
||||
server.listener.submission.protocol = "smtp"
|
||||
server.listener.submissions.bind = "0.0.0.0:465"
|
||||
server.listener.submissions.protocol = "smtp"
|
||||
server.listener.submissions.tls.implicit = true
|
||||
server.max-connections = 8192
|
||||
server.socket.backlog = 1024
|
||||
server.socket.nodelay = true
|
||||
server.socket.reuse-addr = true
|
||||
server.socket.reuse-port = true
|
||||
storage.blob = "rocksdb"
|
||||
storage.data = "rocksdb"
|
||||
storage.directory = "ldap"
|
||||
storage.fts = "rocksdb"
|
||||
storage.lookup = "rocksdb"
|
||||
store.rocksdb.compression = "lz4"
|
||||
store.rocksdb.path = "/opt/stalwart/data"
|
||||
store.rocksdb.type = "rocksdb"
|
||||
tracer.console.ansi = true
|
||||
tracer.console.buffered = true
|
||||
tracer.console.enable = true
|
||||
tracer.console.level = "trace"
|
||||
tracer.console.lossy = false
|
||||
tracer.console.multiline = false
|
||||
tracer.console.type = "stdout"
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
services:
|
||||
|
||||
opencloud:
|
||||
command: [ "-c", "opencloud init || true; dlv --listen=:40000 --headless=true --check-go-version=false --api-version=2 --accept-multiclient exec /usr/bin/opencloud server" ]
|
||||
ports:
|
||||
- 40000:40000
|
||||
@@ -19,11 +19,6 @@ services:
|
||||
- "--entryPoints.http.http.redirections.entryPoint.to=https"
|
||||
- "--entryPoints.http.http.redirections.entryPoint.scheme=https"
|
||||
- "--entryPoints.https.address=:443"
|
||||
# http2 optimizations
|
||||
- "--entryPoints.https.http2.maxConcurrentStreams=512"
|
||||
- "--serversTransport.maxIdleConnsPerHost=100"
|
||||
# allow self signed certificate from OpenCloud
|
||||
- "--serversTransport.insecureSkipVerify=true"
|
||||
# change default timeouts for long-running requests
|
||||
# this is needed for webdav clients that do not support the TUS protocol
|
||||
- "--entryPoints.https.transport.respondingTimeouts.readTimeout=12h"
|
||||
@@ -36,6 +31,7 @@ services:
|
||||
- "--accessLog=true"
|
||||
- "--accessLog.format=json"
|
||||
- "--accessLog.fields.headers.names.X-Request-Id=keep"
|
||||
- "--accessLog.fields.headers.names.Trace-Id=keep"
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
|
||||
@@ -57,6 +57,8 @@ services:
|
||||
KC_FEATURES: impersonation
|
||||
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN_USER:-admin}
|
||||
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin}
|
||||
ports:
|
||||
- "8080:8080"
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.keycloak.entrypoints=https"
|
||||
|
||||
@@ -24,6 +24,7 @@ services:
|
||||
OC_LDAP_SERVER_WRITE_ENABLED: "false" # assuming the external ldap is not writable
|
||||
# OC_RUN_SERVICES specifies to start all services except glauth, idm and accounts. These are replaced by external services
|
||||
OC_EXCLUDE_RUN_SERVICES: idm
|
||||
STALWART_AUTH_DIRECTORY: "ldap"
|
||||
|
||||
ldap-server:
|
||||
image: bitnamilegacy/openldap:2.6
|
||||
@@ -39,6 +40,9 @@ services:
|
||||
LDAP_TLS_KEY_FILE: /opt/bitnami/openldap/share/openldap.key
|
||||
LDAP_ROOT: "dc=opencloud,dc=eu"
|
||||
LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASSWORD:-admin}
|
||||
LDAP_CONFIGURE_PPOLICY: "yes"
|
||||
LDAP_PPOLICY_USE_LOCKOUT: "no"
|
||||
LDAP_PPOLICY_HASH_CLEARTEXT: "no"
|
||||
ports:
|
||||
- "127.0.0.1:389:1389"
|
||||
- "127.0.0.1:636:1636"
|
||||
|
||||
@@ -25,7 +25,7 @@ services:
|
||||
OC_LOG_COLOR: "${LOG_PRETTY:-false}"
|
||||
OC_LOG_PRETTY: "${LOG_PRETTY:-false}"
|
||||
# do not use SSL between Traefik and OpenCloud
|
||||
PROXY_TLS: "true"
|
||||
PROXY_TLS: "false"
|
||||
# make the REVA gateway accessible to the app drivers
|
||||
GATEWAY_GRPC_ADDR: 0.0.0.0:9142
|
||||
# INSECURE: needed if OpenCloud / Traefik is using self generated certificates
|
||||
@@ -58,6 +58,11 @@ services:
|
||||
COMPANION_DOMAIN: ${COMPANION_DOMAIN:-companion.opencloud.test}
|
||||
# enable to allow using the banned passwords list
|
||||
OC_PASSWORD_POLICY_BANNED_PASSWORDS_LIST: banned-password-list.txt
|
||||
IDM_REVASVC_PASSWORD: "admin"
|
||||
AUTH_BASIC_LDAP_BIND_PASSWORD: "admin"
|
||||
USERS_LDAP_BIND_PASSWORD: "admin"
|
||||
GROUPS_LDAP_BIND_PASSWORD: "admin"
|
||||
IDM_LDAPS_ADDR: 0.0.0.0:9235
|
||||
volumes:
|
||||
- ./config/opencloud/app-registry.yaml:/etc/opencloud/app-registry.yaml
|
||||
- ./config/opencloud/csp.yaml:/etc/opencloud/csp.yaml
|
||||
@@ -72,7 +77,6 @@ services:
|
||||
- "traefik.http.routers.opencloud.tls.certresolver=http"
|
||||
- "traefik.http.routers.opencloud.service=opencloud"
|
||||
- "traefik.http.services.opencloud.loadbalancer.server.port=9200"
|
||||
- "traefik.http.services.opencloud.loadbalancer.server.scheme=https"
|
||||
logging:
|
||||
driver: ${LOG_DRIVER:-local}
|
||||
restart: always
|
||||
|
||||
36
devtools/deployments/opencloud_full/stalwart.yml
Normal file
36
devtools/deployments/opencloud_full/stalwart.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
services:
|
||||
traefik:
|
||||
networks:
|
||||
opencloud-net:
|
||||
aliases:
|
||||
- ${STALWART_DOMAIN:-stalwart.opencloud.test}
|
||||
|
||||
stalwart:
|
||||
image: ghcr.io/stalwartlabs/stalwart:v0.15.0-alpine
|
||||
hostname: ${STALWART_DOMAIN:-stalwart.opencloud.test}
|
||||
networks:
|
||||
- opencloud-net
|
||||
ports:
|
||||
- "127.0.0.1:143:143"
|
||||
- "127.0.0.1:993:993"
|
||||
- "127.0.0.1:1465:465"
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- "./config/stalwart/${STALWART_AUTH_DIRECTORY:-idmldap}.toml:/opt/stalwart/etc/config.toml"
|
||||
- stalwart-data:/opt/stalwart/data
|
||||
environment:
|
||||
STALWART_AUTH_DIRECTORY: "${STALWART_AUTH_DIRECTORY:-idmldap}"
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.stalwart.entrypoints=https"
|
||||
- "traefik.http.routers.stalwart.rule=Host(`${STALWART_DOMAIN:-stalwart.opencloud.test}`)"
|
||||
- "traefik.http.routers.stalwart.tls.certresolver=http"
|
||||
- "traefik.http.routers.stalwart.service=stalwart"
|
||||
- "traefik.http.services.stalwart.loadbalancer.server.port=8080"
|
||||
logging:
|
||||
driver: ${LOG_DRIVER:-local}
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
stalwart-data:
|
||||
343
docs/adr/0002-groupware-authentication-with-stalwart.md
Normal file
343
docs/adr/0002-groupware-authentication-with-stalwart.md
Normal file
@@ -0,0 +1,343 @@
|
||||
---
|
||||
title: "Authentication with Stalwart"
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
In a groupware environment, not every user will always use the OpenCloud UI to read their emails, some will resort to other [MUAs (Mail User Agents)](https://en.wikipedia.org/wiki/Email_client) that support a subset of features, use older protocols (IMAP, POP, SMTP, CalDAV, CardDAV) and lesser authentication methods (basic authentication). Those email clients will talk to Stalwart directly, as opposed to the OpenCloud UI which will make use of APIs of the OpenCloud Groupware service, since those protocols are provided by Stalwart and implementing them in OpenCloud would offer very little benefits, but definitely a lot of (almost completely) unnecessary effort.
|
||||
|
||||
Those protocols and operations that bypass the OpenCloud UI also need to be authenticated, this in and by Stalwart, and we need to find the best fitting approach that fulfills most or all of the following constraints:
|
||||
|
||||
### Single Provisioning
|
||||
|
||||
We want to avoid multiple provisioning of users, groups, passwords and other resources as much as possible.
|
||||
While it is possible to have e.g. OpenCloud's user management also perform [Management API](https://stalw.art/docs/category/management-api/) calls, one still inevitably ends up in situations where users, user passwords, or other resources are not in sync, which becomes complex to debug and fix, and should thus be avoided if possible.
|
||||
|
||||
To do so, we should strive to have a single source of truth regarding users, their passwords, and similar resources and attributes such as groups, roles, application passwords, etc...
|
||||
|
||||
### Attack Detection
|
||||
|
||||
Coordinated attacks such as [denial of service](https://en.wikipedia.org/wiki/Denial-of-service_attack) attempts don't necessarily focus on a single protocol but are commonly multi-pronged, e.g. by brute forcing the [OIDC API](https://www.keycloak.org/docs/latest/authorization_services/index.html#token-endpoint), the OpenCloud Groupware API, IMAP and SMTP, \*DAV protocols, etc...
|
||||
|
||||
In order to detect those as well as to quickly react by blacklisting clients that are identified to attempt such attacks, it is useful to have a single authentication service for all the components of the system, all protocols, all clients (e.g. [PowerDNS Weakforced](https://github.com/PowerDNS/weakforced), [Nauthilus](https://nauthilus.org/), ...)
|
||||
|
||||
Furthermore, such services typically make use of [DNSBL/RBL services](https://en.wikipedia.org/wiki/Domain_Name_System_blocklist) that allow IP addresses of botnets to be blocked across many services of many providers as a shared defense mechanism.
|
||||
|
||||
As a bonus, a centralized authentication component can also provide metrics and observability capabilities across all those protocols.
|
||||
|
||||
### Custom Authentication Implementations
|
||||
|
||||
Some customers might want custom authentication implementations to integrate with their environment, in which case we would want those to be done once and in the technology stack we're all most familiar with (thus as a service in Go in the OpenCloud framework, and not e.g. a Lua script in Nauthilus, or a Rust plugin in Stalwart, etc...)
|
||||
|
||||
## Decision Drivers
|
||||
|
||||
TODO
|
||||
|
||||
*
|
||||
|
||||
## Considered Options
|
||||
|
||||
First off, here is a brief explanation of each of the scenarios that we potentially or absolutely need to support, which we will explore for each implementation option:
|
||||
|
||||
* MUAs with basic authentication
|
||||
* these are external mail clients (Thunderbird, Apple Mail, ...) with which users authenticate using legacy protocols (IMAP, POP3, SMTP) and their primary username and password in clear text (encrypted through the mandatory use of TLS)
|
||||
* MUAs with application password authentication
|
||||
* these are external mail clients (Thunderbird, Apple Mail, ...) with which users authenticate using legacy protocols (IMAP, POP3, SMTP) and one of the application passwords that they created in the OpenCloud UI, which is a useful security mechanism as it reduces the attack surface when one such password is leaked or discovered
|
||||
* MUAs with SASL bearer token authentication
|
||||
* these are more modern external mail clients (Thunderbird) with which users authenticate using legacy protocols (IMAP, POP3, SMTP) but more secure OIDC token based authentication (SASL OAUTHBEARER or SASL XOAUTH2), which closely resembles the OIDC authentication used by the OpenCloud UI towards the OpenCloud backends
|
||||
* JMAP clients with basic authentication
|
||||
* modern mail clients (Thunderbird) that speak the JMAP protocol over HTTP and authenticate using their primary username and password in clear text (encrypted through the use of HTTPS)
|
||||
* JMAP clients with bearer token authentication
|
||||
* modern mail clients (Thunderbird) that speak the JMAP protocol over HTTP and authenticate using an OIDC token (JWT) obtained from an IDP (typically KeyCloak)
|
||||
* OpenCloud Groupware with master authentication
|
||||
* the OpenCloud UI client uses APIs from the OpenCloud Groupware backend (and authenticates using OIDC)
|
||||
* the OpenCloud Groupware backend, in turn, performs JMAP operations with Stalwart, and authenticates using Stalwart's shared secret master authentication protocol
|
||||
* OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud UI client uses APIs from the OpenCloud Groupware backend (and authenticates using OIDC)
|
||||
* the OpenCloud Groupware backend, in turn, performs JMAP operations with Stalwart, and authenticates against Stalwart using bearer authentication with JWTs that it generates itself
|
||||
* in the future, that JWT might also be the JWT that the OpenCloud UI used to authenticate against the OpenCloud Groupware in the first place
|
||||
|
||||
### Stalwart with the LDAP Directory
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
s(Stalwart)
|
||||
l(LDAP)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
c -- JMAP --> s
|
||||
s -- LDAP --> l
|
||||
```
|
||||
|
||||
Clients authenticate directly against Stalwart, that is configured to use an LDAP authentication Directory.
|
||||
An LDAP server (e.g. OpenLDAP) is needed as part of the infrastructure.
|
||||
OpenCloud also has to make use of the same LDAP server.
|
||||
|
||||
* ✅ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin supports plain text authentication by looking up the userPassword attribute in the LDAP server
|
||||
* ❌ MUAs with application password authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin does not support application password as it is hardwired to look up the password in the userPassword attribute in the LDAP server
|
||||
* even if it did support looking up alternative passwords in LDAP, this would hardly be practical as the application passwords are currently created and stored in OpenCloud, which would need to be modified to store them in LDAP in the first place
|
||||
* ❌ MUAs with SASL bearer token authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin does not support verifying OIDC tokens
|
||||
* ✅ JMAP clients with basic authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin supports plain text authentication by looking up the userPassword attribute in the LDAP server
|
||||
* ❌ JMAP clients with bearer token authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin does not support verifying OIDC tokens
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ❌ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart's LDAP Directory plugin does not support verifying OIDC tokens
|
||||
|
||||
### Stalwart with the OIDC Directory
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
s(Stalwart)
|
||||
o(IDP)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
c -- JMAP --> s
|
||||
s -- OIDC HTTP --> o
|
||||
```
|
||||
|
||||
Clients authenticate directly against Stalwart, that is configured to use an OIDC authentication Directory.
|
||||
An OIDC IDP (server) is needed as part of the infrastructure, e.g. KeyCloak.
|
||||
Optionally, an LDAP server (e.g. OpenLDAP) might be used as well, and KeyCloak would look up users and their credentials in LDAP.
|
||||
|
||||
OpenCloud also has to make use of the same LDAP server, or would need to be modified to be capable of only making use of an OIDC IDP (which would include limitations that are yet to be resolved, e.g. the option of using KeyCloak Admin APIs to retreieve groups, group members, ...)
|
||||
|
||||
* ❌ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not support plain text authentication
|
||||
* ❌ MUAs with application password authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not support application passwords
|
||||
* ❓ MUAs with SASL bearer token authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not currently support external IDPs, but is expected to in future versions
|
||||
* as of Stalwart 0.12, this would only work if Stalwart itself is used as the IDP when acquiring a token
|
||||
* ❌ JMAP clients with basic authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not support plain text authentication
|
||||
* ❓ JMAP clients with bearer token authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not currently support external IDPs, but is expected to in future versions
|
||||
* as of Stalwart 0.12, this would only work if Stalwart itself is used as the IDP when acquiring a token
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ❓ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart's OIDC Directory plugin does not currently support external IDPs, but is expected to in future versions
|
||||
* as of Stalwart 0.12, this would only work if Stalwart itself is used as the IDP when acquiring a token, which is not the case with this approach as the tokens are generated by the Groupware backend itself
|
||||
|
||||
### Stalwart with the Internal Directory
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
s(Stalwart)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
c -- JMAP --> s
|
||||
```
|
||||
|
||||
Clients authenticate directly against Stalwart, that is configured to use an Internal authentication Directory.
|
||||
Neither an OIDC IDP nor an LDAP server are needed as part of the infrastructure, as principal resources (users, groups) and their credentials exist in Stalwart's storage.
|
||||
|
||||
OpenCloud would not be capable of accessing those resources, which means that provisioning of groups, users, user passwords must be duplicated and kept in sync between Stalwart and OpenCloud.
|
||||
|
||||
* ✅ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin supports plain text authentication
|
||||
* ✅ MUAs with application password authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin supports application passwords
|
||||
* users are able to create those themselves using the self-service web UI of Stalwart
|
||||
* they are not shared with the OpenCloud application passwords though and would need to be provisioned into Stalwart when created in OpenCloud to provide a single UI
|
||||
* ❌ MUAs with SASL bearer token authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin does not support OIDC token authentication
|
||||
* ✅ JMAP clients with basic authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin supports plain text authentication
|
||||
* ❌ JMAP clients with bearer token authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin does not support OIDC token authentication
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ❌ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart's Internal Directory plugin does not support OIDC token authentication
|
||||
|
||||
### Stalwart with the OpenCloud Authentication API
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
s(Stalwart)
|
||||
o(OpenCloud)
|
||||
l(LDAP)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
c -- JMAP --> s
|
||||
s -- REST --> o
|
||||
o -- LDAP --> l
|
||||
```
|
||||
|
||||
Clients authenticate directly against Stalwart, that is configured to use an "External" authentication Directory, that is yet to be developed. (warning)
|
||||
Its protocol is currently not defined, but not particularly relevant at this time, as long as it supports accepting basic and bearer authentication in order to authenticate both username and password credentials as well as OIDC tokens.
|
||||
|
||||
That External Directory implementation forwards the basic or bearer credentials to an endpoint in the OpenCloud backend, that the responds with whether the authentication is successful or not, as well as with additional information that is needed for Stalwart (email address, display name, groups, roles, ...)
|
||||
|
||||
* ✅ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's External Directory supports plain text authentication by relaying the authentication operation to the OpenCloud backend, which can then authenticate users by username and password using an LDAP server
|
||||
* note that this option requires having an LDAP server in the environment, including having it accessible by OpenCloud
|
||||
* if that is not the case, then a viable option is also to support OIDC tokens and application passwords
|
||||
* to clarify: this scenario is only about supporting authentication using the "primary" username and password
|
||||
* ✅ MUAs with application password authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's External Directory supports application password authentication by relaying the authentication operation to the OpenCloud backend, which can then authenticate against its list of application passwords
|
||||
* this is the ideal scenario for application passwords, since they are already supported by OpenCloud, and can be created and managed using the OpenCloud UI
|
||||
* relaying the authentication operation to OpenCloud also prevents the need for duplicate provisioning of application passwords
|
||||
* ✅ MUAs with SASL bearer token authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's External Directory supports OIDC token authentication by relaying the authentication operation to the OpenCloud backend, which can then either perform local token inspection and authentication by verifying the token's signature, or use the OIDC IDP's token introspection endpoint
|
||||
* ✅ JMAP clients with basic authentication
|
||||
* JMAP clients authenticate directly against Stalwart
|
||||
* Stalwart's External Directory supports plain text authentication by relaying the authentication operation to the OpenCloud backend, which can then authenticate users by username and password using an LDAP server
|
||||
* the same limitations/requirements as for the "MUAs with basic authentication" scenario apply here as well
|
||||
* ✅ JMAP clients with bearer token authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's External Directory supports OIDC token authentication by relaying the authentication operation to the OpenCloud backend, which can then either perform local token inspection and authentication by verifying the token's signature, or use the OIDC IDP's token introspection endpoint
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ✅ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* in the worst case, the External Directory plugin in Stalwart would also perform a forwarding of the authentication operation to OpenCloud, which would obviously be able to verify a token it has created
|
||||
* an optimization might be possible here, if the External Directory implementation permits for the configuration of specific issuers which should then be verifying against a JWK set directly, whereas the fallback behaviour would be to query the OpenCloud Authentication API
|
||||
|
||||
### Stalwart with Nauthilus and LDAP
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
s(Stalwart)
|
||||
n(Nauthilus)
|
||||
l(LDAP)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
c -- JMAP --> s
|
||||
s -- REST --> n
|
||||
n -- LDAP --> l
|
||||
```
|
||||
|
||||
In this scenario, we introduce the [Nauthilus authentication service](https://nauthilus.org/), which has its own API but also a KeyCloak integration plugin.
|
||||
It supports various backends and can also be scripted for more complex combinations.
|
||||
|
||||
⚠️ It would require the implementation of a Stalwart Nauthilus Directory, **that is yet to be developed**.
|
||||
|
||||
We do not make use of any OpenCloud Authentication API but, instead, attempt to have everything go through Nauthilus instead, backed by an LDAP server that then contains the users, groups, and user passwords.
|
||||
|
||||
The upside of using Nauthilus is that it does brute force attack detection and can provide metrics across multiple protocols and clients in a centralized fashion.
|
||||
|
||||
* ✅ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's Nauthilus Directory supports plain text authentication by relaying the authentication operation to Nauthilus, e.g. using its JSON API
|
||||
* Nauthilus provides a response that contains user attributes from LDAP (display name, email addresses, ...)
|
||||
* ❓ MUAs with application password authentication
|
||||
* Nauthilus has no support for application passwords in itself
|
||||
* a Lua plugin could potentially be used in Nauthilus to detect whether the clear text password matches a regular expression for application passwords and, if that is the case, first attempt to verify it through an API call (that does not exist yet) to the OpenCloud backend, but that would definitely be more complex and less elegant than having a single API
|
||||
* ❓ MUAs with SASL bearer token authentication
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication
|
||||
* ✅ JMAP clients with basic authentication
|
||||
* Stalwart's Nauthilus Directory supports plain text authentication by relaying the authentication operation to Nauthilus, e.g. using its JSON API
|
||||
* Nauthilus provides a response that contains user attributes from LDAP (display name, email addresses, ...)
|
||||
* ❓ JMAP clients with bearer token authentication
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ❓ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication
|
||||
* an optimization might be possible here, if the Nauthilus Directory implementation permits for the configuration of specific issuers which should then be verifying against a JWK set directly, whereas the fallback behaviour would be to query the Nauthilus API, but that does sound like a stretch to fit into the concept
|
||||
|
||||
### Stalwart with Nauthilus and an OpenCloud Authentication API
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
c(client)
|
||||
j(client)
|
||||
s(Stalwart)
|
||||
n(Nauthilus)
|
||||
o(OpenCloud)
|
||||
l(LDAP)
|
||||
k(Keycloak)
|
||||
|
||||
c -- IMAP/SMTP --> s
|
||||
j -- JMAP --> s
|
||||
s -- REST --> n
|
||||
subgraph internal auth
|
||||
n -- REST --> o
|
||||
o -- LDAP --> l
|
||||
o -- OIDC --> k
|
||||
end
|
||||
```
|
||||
|
||||
This option also makes use of the [Nauthilus authentication service](https://nauthilus.org/), but instead of it using LDAP to resolve users, we would either make use of its Lua scripting abilities to implement a backend that performs HTTP calls to an OpenCloud Authentication API, or implement an additional Nauthilus backend that uses the Nauthilus API to delegate to another instance, which would then be the OpenCloud Authentication API with support for the Nauthilus API.
|
||||
|
||||
⚠️ As with the previous option, it would require the implementation of a Stalwart Nauthilus Directory, **that is yet to be developed**.
|
||||
|
||||
Interestingly, if the OpenCloud Authentication API follows the Nauthilus API, this scenario can easily be degraded by dropping Nauthilus and, instead, having all services talk to the OpenCloud Authentication API directly.
|
||||
|
||||
* ✅ MUAs with basic authentication
|
||||
* MUAs authenticate directly against Stalwart
|
||||
* Stalwart's Nauthilus Directory supports plain text authentication by relaying the authentication operation to Nauthilus, e.g. using its JSON API
|
||||
* Nauthilus provides a response that contains user attributes from LDAP (display name, email addresses, ...)
|
||||
* ✅ MUAs with application password authentication
|
||||
* Nauthilus would forward the authentication request to the OpenCloud Authentication API, which would support application passwords
|
||||
* ❓ MUAs with SASL bearer token authentication
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication and whether it would be able to forward such requests to the OpenCloud Authentication API
|
||||
* ✅ JMAP clients with basic authentication
|
||||
* Stalwart's Nauthilus Directory supports plain text authentication by relaying the authentication operation to Nauthilus, e.g. using its JSON API
|
||||
* Nauthilus then forwards that request to the OpenCloud Authentication API
|
||||
* the OpenCloud Authentication API, and then Nauthilus, provides a response that contains user attributes from LDAP (display name, email addresses, ...) or claims from the JWT
|
||||
* ❓ JMAP clients with bearer token authentication
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication and whether it would be able to forward such requests to the OpenCloud Authentication API
|
||||
* ✅ OpenCloud Groupware with master authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* Stalwart detects and supports clear text password master authentication regardless of the Directory that is being used, and verifies it against the shared secret password that is configured in the server
|
||||
* ❓ OpenCloud Groupware with generated token authentication
|
||||
* the OpenCloud Groupware backend authenticates directly against Stalwart
|
||||
* it is currently unclear whether Nauthilus supports OIDC token authentication and whether it would be able to forward such requests to the OpenCloud Authentication API
|
||||
|
||||
> [!IMPORTANT]
|
||||
> We need to clarify whether the Nauthilus API allows for a JWT to be submitted for the authentication request, and not only username and password – not to secure the request in itself, but to forward an OIDC token based authentication attempt as part of the payload.
|
||||
|
||||
### Comparing Options
|
||||
|
||||
| | MUA basic | MUA app password | MUA sasl | JMAP clients with basic auth | JMAP clients with JWT auth | Groupware Middleware with master auth | Groupware Middleware with JWT auth |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| Stalwart 0.12 with LDAP Directory | ✅ MUA → Stalwart | ❌ not supported with LDAP | ❌ not supported with LDAP | ✅ | ❌ | ✅ | ❌ |
|
||||
| Stalwart 0.12 with OIDC Directory | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
||||
| Stalwart 0.12 with Internal Directory | ✅ MUA → Stalwart, must be provisioned in Stalwart | ✅ MUA → Stalwart, must be provisioned in Stalwart | ❌ | ❌ | ❌ unless using Stalwart as IDP | ✅ | ❌ |
|
||||
| Stalwart + OpenCloud Authentication API | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ | ✅ |
|
||||
| Stalwart + Nauthilus + LDAP | ✅ MUA → IMAP proxy → Nauthilus → LDAP | ❌ | ❌ | ✅ | ❌ | ✅ | ❌ |
|
||||
| Stalwart + Nauthilus + OpenCloud Authentication API | ✅ MUA → IMAP proxy → Nauthilus → OpenCloud | ✅ MUA → IMAP proxy → Nauthilus → OpenCloud | ✅ MUA → IMAP proxy → Nauthilus → OpenCloud | ✅ MUA → IMAP proxy → Nauthilus → OpenCloud | ✅ MUA → IMAP proxy → Nauthilus → OpenCloud | ✅ | ✅ |
|
||||
| Stalwart + Nauthilus-like OpenCloud Authentication API | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ MUA → Stalwart → OpenCloud | ✅ | ✅ |
|
||||
64
docs/adr/0003-groupware-microservice-vs-oc-integration.md
Normal file
64
docs/adr/0003-groupware-microservice-vs-oc-integration.md
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
status: proposed
|
||||
date: 2025-06-24
|
||||
author: Pascal Bleser <p.bleser@opencloud.eu>
|
||||
decision-makers:
|
||||
consulted:
|
||||
informed:
|
||||
title: "Implementing Groupware as a separate Microservice vs integrated in the OpenCloud Stack"
|
||||
template: https://raw.githubusercontent.com/adr/madr/refs/tags/4.0.0/template/adr-template.md
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
Should the Groupware backend be an independent microservice or be part of the OpenCloud single binary framework?
|
||||
|
||||
The OpenCloud backend is built on a framework that
|
||||
|
||||
* implements token based authentication between services
|
||||
* allows for a "single binary" deployment mode that runs all services within that one binary
|
||||
* integrates services such as a NATS event bus
|
||||
|
||||
This decision is about whether the Groupware backend service should be implemented within that framework or, instead, be implemented as a standalone backend service.
|
||||
|
||||
## Decision Drivers
|
||||
|
||||
* single binary deployment strategy is potentially important (TODO how important is it really? stakeholders:?)
|
||||
|
||||
## Considered Options
|
||||
|
||||
* have the Groupware Middleware as an independent microservice
|
||||
* have the Groupware Middleware implemented within the existing OpenCloud framework
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
TODO
|
||||
|
||||
### Consequences
|
||||
|
||||
TODO
|
||||
|
||||
### Confirmation
|
||||
|
||||
TODO
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
### Independent Microservice
|
||||
|
||||
* (potentially) good: be free from technical decisions made for the existing OpenCloud stack, to avoid carrying potential technical baggage
|
||||
* (potentially) good: make use of a framework that is more fitting for the tasks the Groupware backend needs to accomplish
|
||||
* bad: re-implement framework components that already exist, with the need to maintain those in two separate codebases, or the added complexity of a shared library repository
|
||||
* bad: not have the ability to include the Groupware backend in the single binary deployment
|
||||
* neutral: a separate code repository and delivery for the Groupware backend, which might or might not be of advantage
|
||||
* neutral: may be implemented on a completely different technology stack, including the programming language
|
||||
|
||||
### Part of the framework
|
||||
|
||||
* good: fit into the opinionated choices that were made for the OpenCloud framework so far
|
||||
* good: many aspects are already implemented in the current framework and can be made use of, potentially enhanced for the needs of the Groupware backend
|
||||
* good: the ability to include the Groupware backend in the single binary deployment
|
||||
* neutral: be in the same code repository and part of the same delivery as other services in OpenCloud
|
||||
* neutral: must be implemented in Go on top of the same technology stack
|
||||
294
docs/adr/0004-groupware-resource-linking.md
Normal file
294
docs/adr/0004-groupware-resource-linking.md
Normal file
@@ -0,0 +1,294 @@
|
||||
---
|
||||
status: proposed
|
||||
date: 2025-06-24
|
||||
author: Pascal Bleser <p.bleser@opencloud.eu>
|
||||
decision-makers:
|
||||
consulted:
|
||||
informed:
|
||||
title: "Resource Linking"
|
||||
template: https://raw.githubusercontent.com/adr/madr/refs/tags/4.0.0/template/adr-template.md
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
Which semantic and technical approach to take in order to provide strong integration of the various products and capabilities of OpenCloud, OpenTalk, and potentially other products as well?
|
||||
|
||||
## Decision Drivers
|
||||
|
||||
* a strong integration that allows users to access resources and relationships without having to switch views, which translates into a "mental switch" as well
|
||||
* an innovative approach that differs from the traditional way groupware applications have been designed in the past
|
||||
* TODO more decision drivers from PM
|
||||
* a model that is open and generic enough to integrate many different types of resources and relationships
|
||||
* a model that allows for independent and incremental upgrades to the resources and relationships that can be contributed by each service
|
||||
|
||||
## Considered Options
|
||||
|
||||
* resource linking
|
||||
* application launchers
|
||||
* TODO? can we come up with more ideas?
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
TODO
|
||||
|
||||
### Consequences
|
||||
|
||||
TODO
|
||||
|
||||
### Confirmation
|
||||
|
||||
TODO
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
### Resource Linking
|
||||
|
||||
This concept primarily resides on the idea of having resources, which have attributes, and relations between them, pretty much as [RDF (Resource Description Framework)](https://www.w3.org/RDF/) does, where the Groupware backend provides services to explore relations of a given resource.
|
||||
|
||||
* good: decoupling of UI, backends as well as other participants, as backends can gradually evolve the relationships and resources they understand and can contribute to over time, as well as for the UI that may just silently ignore resources it does not support yet or does not want to present to the user
|
||||
* good: potential for an asynchronous architecture that would enable the UI to present some resources early without having to wait for those that require more processing time or are provided by services that happen to be under heavier load
|
||||
* good: it should provide ammunition for a modern and original UI that is centered around resources and relationships rather than the usual visual paradigms
|
||||
* bad: it might be a challenge to implement this approach in a performant way with rapid response times, as it could cause additional complexity and storage services (e.g. to denormalize reverse indexes, cache expensive resource graphs, etc...)
|
||||
|
||||
#### URNs
|
||||
|
||||
Each resource has a unique identifier, for which [URNs (Uniform Resource Names)](https://www.rfc-editor.org/rfc/rfc1737) seem the best representation.
|
||||
|
||||
URNs are composed of
|
||||
|
||||
* a namespace identifier
|
||||
* a namespace-specific string
|
||||
|
||||
As a convention, we will use the following:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><code>urn:</code></th>
|
||||
<th>ns</th>
|
||||
<th colspan="2">namespace specific string</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>urn:</code></td>
|
||||
<td><code>oc:</code></td>
|
||||
<td><code><type>:</code></td>
|
||||
<td><code><unique identifier>:</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
##### Examples
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><code>urn:</code></th>
|
||||
<th>namespace</th>
|
||||
<th>type</th>
|
||||
<th>unique id</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>urn:</code></td>
|
||||
<td><code>oc:</code></td>
|
||||
<td><code>user:</code></td>
|
||||
<td><code>camina.drummer</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>urn:</code></td>
|
||||
<td><code>oc:</code></td>
|
||||
<td><code>contact:</code></td>
|
||||
<td><code>klaes.ashford</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>urn:</code></td>
|
||||
<td><code>oc:</code></td>
|
||||
<td><code>event:</code></td>
|
||||
<td><code>dd4ea520-e414-41e1-b545-b1c7d4ce57e7</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>urn:</code></td>
|
||||
<td><code>oc:</code></td>
|
||||
<td><code>mail:</code></td>
|
||||
<td><code><1e8074e8-cd56-4358-9f9e-f17cb701b950@opa.org></code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
#### Exploration API
|
||||
|
||||
Whenever the user puts a resource into focus in the OpenCloud Groupware UI (i.e. by selecting/clicking that resource, e.g. the sender of an email), it may send a request to the Groupware service API to inquire about related resources.
|
||||
|
||||
What those related resources are still stands to be determined, but examples could be along the lines of
|
||||
|
||||
* unread emails from the same sender
|
||||
* emails exchanged with that sender in the last 7 days
|
||||
* files recently shared with that user
|
||||
* spaces or groups in common with that user
|
||||
* OpenTalk meetings planned within the next 3 days
|
||||
|
||||
In order to decouple the Groupware service from which resources and relations are supported,
|
||||
|
||||
* whenever such an exploration request is received, the Groupware service forwards it to all known services, in a "fan-out" model
|
||||
* each service can understand the focused resource, or not, but if it does it may return related resources that it is capable of providing using its data model (e.g. OpenTalk providing related meeting resources, OpenCloud Groupware providing related calendar events, contacts, mails, etc...)
|
||||
* ideally, that happens in an asynchronous fashion, using e.g. [SSE (Server Side Events)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) to push results to the OpenCloud UI to avoid having to wait for the slowest contributor, although that pushes the "reduce" part of this ["map-reduce" operation](https://en.wikipedia.org/wiki/MapReduce) to the client
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
c(client)
|
||||
subgraph backend
|
||||
a(opencloud api)
|
||||
g(groupware)
|
||||
ot(opentalk)
|
||||
u(users)
|
||||
s(stalwart)
|
||||
k(keycloak)
|
||||
end
|
||||
subgraph storage
|
||||
ots@{ shape: cyl, label: "opentalk\nstorage"}
|
||||
ss@{ shape: cyl, label: "stalwart\nstorage"}
|
||||
l@{ shape: cyl, label: "ldap"}
|
||||
end
|
||||
c-->|/related/urn:oc:user:camina.drummer|a
|
||||
a-->|/related/urn:oc:user:camina.drummer|g
|
||||
g-->s
|
||||
s-->ss
|
||||
a-->|/related/urn:oc:user:camina.drummer|ot
|
||||
ot-->ots
|
||||
a-->|/related/urn:oc:user:camina.drummer|u
|
||||
u-->k
|
||||
k-->l
|
||||
|
||||
ot-.->|urn:oc:meeting:232403bc-b98f-4643-a917-80bdcfc7aaba|a
|
||||
g-.->|urn:oc:event:e5193ad3-8f1c-4162-8593-69fe659bcc08|a
|
||||
```
|
||||
|
||||
This allows a decoupling of all the participants, enabling each service to add, remove or alter relationships that it is able to contribute for a given resource type.
|
||||
|
||||
Obviously, the UI needs to be able to understand resource types to know how to represent them, but if it silently ignores resource types that it does not know of, backends can evolve independently from the UI.
|
||||
|
||||
#### JSON-LD
|
||||
|
||||
[JSON-LD (JSON for Linking Data)](https://json-ld.org/) seems like a potent representation format for those relationships in a REST environment.
|
||||
|
||||
It could look something like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"@context": {
|
||||
"@user": "https://schema.opencloud.eu/user.jsonld",
|
||||
"link": "https://schema.opencloud.eu/linked.jsonld"
|
||||
},
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:cdrummer",
|
||||
"name": "Camina Drummer",
|
||||
"email": "camina@opa.org",
|
||||
"roles": ["admin", "pirate"],
|
||||
"link:rooms": [
|
||||
{
|
||||
"@context": {
|
||||
"@room": "https://meta.opencloud.eu/room.jsonld",
|
||||
"link": "https://schema.opencloud.eu/linked.jsonld"
|
||||
},
|
||||
"@id": "urn:oc:room:a3f19df6-6c7d-45fa-b16c-6e168e2a2a43",
|
||||
"name": "OPA Leadership Standup 2355-02-27",
|
||||
"start": "2355-02-27T10:58:15.918Z",
|
||||
"end": "2355-02-27T13:52:59.010Z",
|
||||
"started_by": {
|
||||
"@context": "https://meta.opencloud.eu/user.jsonld",
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:adawes",
|
||||
"name": "Anderson Dawes",
|
||||
"email": "anderson@opa.org"
|
||||
},
|
||||
"link:events": [
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/event.jsonld",
|
||||
"@type": "urn:oc:type:event",
|
||||
"@id": "urn:oc:event:3e041c88-088c-4015-a32e-5560561f6e26",
|
||||
"start": "2355-02-27T11:09:15.918Z",
|
||||
"end": "2355-02-27T13:52:59.010Z",
|
||||
"status": "confirmed",
|
||||
"invited": [
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/user.jsonld",
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:adawes",
|
||||
"name": "Anderson Dawes",
|
||||
"email": "anderson@opa.org"
|
||||
},
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/user.jsonld",
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:kashford",
|
||||
"name": "Klaes Ashford",
|
||||
"email": "klaes@opa.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"members": [
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/contact.jsonld",
|
||||
"@type": "urn:oc:type:contact",
|
||||
"@id": "urn:oc:contact:9ccb247d-a728-4d8f-9259-c28cf6cef567",
|
||||
"name": "Naomi Nagata",
|
||||
"email": "naomo@opa.org"
|
||||
},
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/user.jsonld",
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:adawes",
|
||||
"name": "Anderson Dawes",
|
||||
"email": "anderson@opa.org"
|
||||
},
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/user.jsonld",
|
||||
"@type": "urn:oc:type:user",
|
||||
"@id": "urn:oc:user:kashford",
|
||||
"name": "Klaes Ashford",
|
||||
"email": "klaes@opa.org"
|
||||
}
|
||||
],
|
||||
"chat": {
|
||||
"@context": "https://meta.opencloud.eu/file.jsonld",
|
||||
"@type": "urn:oc:type:file",
|
||||
"@id": "urn:oc:file:OPA:chatlogs/2355/02/27/a3f19df6-6c7d-45fa-b16c-6e168e2a2a43.md",
|
||||
"href": "https://cloud.opencloud.eu/spaces/OPA/chatlogs/2355/02/27/a3f19df6-6c7d-45fa-b16c-6e168e2a2a43.md"
|
||||
}
|
||||
}
|
||||
],
|
||||
"link:mails": [
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/mail.jsonld",
|
||||
"@type": "urn:oc:type:mail",
|
||||
"@id": "583b9b66-c0b3-41ba-bf6c-a02ec5f4a638@smtp-07.opa.org",
|
||||
"subject": "About bosmang Fred Johnson",
|
||||
"date": "2355-01-03T09:39:44.919Z"
|
||||
},
|
||||
...
|
||||
],
|
||||
"link:shares": [
|
||||
{
|
||||
"@context": "https://meta.opencloud.eu/share.jsonld",
|
||||
"@type": "urn:oc:type:share",
|
||||
"@id": "841ef259-584d-4ce6-827f-b53f900c988d",
|
||||
"filename": "remember the cant.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Application Launchers
|
||||
|
||||
Have a UI that is comprised of multiple more-or-less separate applications, with an application launcher bar, with each application being an icon in itself in that launcher.
|
||||
|
||||
Similar to what e.g. Google does, or Open-Xchange App Suite.
|
||||
|
||||
* bad: does not make for an integrated application paradigm since users still have to context switch between those applications/views to perform tasks
|
||||
|
||||
62
docs/adr/0005-groupware-software-stack.md
Normal file
62
docs/adr/0005-groupware-software-stack.md
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
status: proposed
|
||||
date: 2025-06-25
|
||||
author: Pascal Bleser <p.bleser@opencloud.eu>
|
||||
decision-makers:
|
||||
consulted:
|
||||
informed:
|
||||
title: "Groupware Software Stack"
|
||||
template: https://raw.githubusercontent.com/adr/madr/refs/tags/4.0.0/template/adr-template.md
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
Which software stack to choose for the implementation of the OpenCloud Groupware service?
|
||||
|
||||
## Considered Options
|
||||
|
||||
* [Go](https://go.dev/) with the OpenCloud framework, as it is used in OpenCloud
|
||||
* Rust, as it is a similarly modern language, with know-how in Opentalk
|
||||
* Java with an opinionated microservice framework (e.g. [Micronaut](https://micronaut.io/))
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
The decision was taken to go with the existing Go technology stack used in OpenCloud, since it allows for
|
||||
|
||||
* everyone in the Groupware backend team to contribute
|
||||
* having a single technology stack across all OpenCloud backend features
|
||||
* having the option of a single binary deployment
|
||||
|
||||
### Consequences
|
||||
|
||||
TODO
|
||||
|
||||
### Confirmation
|
||||
|
||||
TODO
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
### Go
|
||||
|
||||
* good: established in the OpenCloud team, with expertise, potentially broadening the team that can contribute to Groupware development
|
||||
* good: make use of the existing infrastructure and framework, including the single binary deployment option
|
||||
* bad: less mature and capable technology stack, potentially problematic with regards to lack of asynchronous I/O and streamed HTTP processing
|
||||
|
||||
### Rust
|
||||
|
||||
* good: shared knowledge with the team of developers at OpenTalk
|
||||
* bad: little to no experience in the current OpenCloud team
|
||||
|
||||
### Java
|
||||
|
||||
* bad: little to no experience in the current OpenCloud team, with exception of the Groupware members
|
||||
* good: extensive experience with Micronaut with one OpenCloud developer
|
||||
* good: opinionated and well documented
|
||||
* good: cloud native
|
||||
* good: mature technology stack
|
||||
* good: asynchronous I/O and virtual threads make for efficient resource usage
|
||||
* potentially bad: likely to not fit well into low resource environments (although native compilation using GraalVM is possible)
|
||||
* potentially bad: prevents the single binary deployment option from including Groupware
|
||||
73
docs/adr/0006-groupware-stalwart-as-backend.md
Normal file
73
docs/adr/0006-groupware-stalwart-as-backend.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
status: proposed
|
||||
date: 2025-06-25
|
||||
author: Pascal Bleser <p.bleser@opencloud.eu>
|
||||
decision-makers:
|
||||
consulted:
|
||||
informed:
|
||||
title: "Stalwart as Groupware Backend"
|
||||
template: https://raw.githubusercontent.com/adr/madr/refs/tags/4.0.0/template/adr-template.md
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
Which Groupware backend should be used?
|
||||
|
||||
## Considered Options
|
||||
|
||||
* [Stalwart](https://stalw.art/), contains not only mail but also collaborative features in an integrated package
|
||||
* traditional IMAP/POP/SMTP stacks (e.g. [Dovecot](https://www.dovecot.org/) + [Postfix](https://www.postfix.org/))
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
The decision was made to go with Stalwart, as it reduces the implementation effort on our end, allowing us for a much faster time-to-market with a significantly smaller team of developers.
|
||||
|
||||
### Consequences
|
||||
|
||||
We will most probably not need to develop much of a calendar or contact stack ourselves, as Stalwart is planning to implement those as part of the upcoming [JMAP](https://jmap.io/spec-core.html) specifications for [contacts](https://jmap.io/spec-contacts.html) and [calendars](https://jmap.io/spec-calendars.html).
|
||||
|
||||
The Groupware API will largely consist of a translation of high-level operations for the UI into JMAP operations sent to Stalwart.
|
||||
|
||||
#### Risks
|
||||
|
||||
On the flip side, there are a number of risks associated with that decision.
|
||||
|
||||
* Stalwart underdelivers on its promises
|
||||
* calendaring provides insufficient features for our implementation (e.g. event series handling being too basic)
|
||||
* not scaling for large deployments
|
||||
* necessary adaptations (e.g. for authentication integration) are rejected upstream
|
||||
* etc...
|
||||
|
||||
### Confirmation
|
||||
|
||||
TODO
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
### Stalwart
|
||||
|
||||
* good: integrated package that contains IMAP/POP, SMTP, anti-spam, AI, encryption at rest and many other features in one
|
||||
* good: modern stack
|
||||
* good: capable of fault tolerance in large deployments through its use of [FoundationDB](https://www.foundationdb.org/)
|
||||
* bad: relatively new project with few to no large scale productive deployments (yet)
|
||||
* bad: significant human [SPoF](https://en.wikipedia.org/wiki/Single_point_of_failure)/[bus factor](https://en.wikipedia.org/wiki/Bus_factor) issue as the development team currently consists of one
|
||||
* good: supports and drives the JMAP protocol ([JMAP Core](https://jmap.io/spec-core.html), [JMAP Mail](https://jmap.io/spec-mail.html), [JMAP Contacts](https://jmap.io/spec-contacts.html), [JMAP Calendars](https://jmap.io/spec-calendars.html), [JMAP Tasks](https://jmap.io/spec-tasks.html), ...),
|
||||
* which provides more high-level operations that we don't need to implement ourselves,
|
||||
* as well as a much cleaner specification that reduces efforts too,
|
||||
* and additionally can be implemented with an efficient stateless HTTP I/O stack
|
||||
* bad: no viable broad JMAP implementation alternatives in case Stalwart does not deliver ([Apache James](https://james.apache.org/) only seems to support a basic subset of JMAP)
|
||||
* good: implements a lot of Groupware "business logic" on its own, reducing the implementation effort on our end,
|
||||
* most notably by not having to deal with IMAP extensions and quirks,
|
||||
* or the complexity of calendar events
|
||||
|
||||
### IMAP/SMTP
|
||||
|
||||
* good: there are a number of alternatives in case a specific implementation does not deliver
|
||||
* good: the best implementation candidates are well-established, used in large amounts of productive deployments, supported by teams of developers
|
||||
* bad: more complex stack composed of numerous components as opposed to an all-in-one implementation
|
||||
* bad: the effort and complexity of having to deal with IMAP,
|
||||
* its complexity due to its extensions and its many quirks,
|
||||
* as well as a significantly less efficient I/O stack that requires stateful session handling
|
||||
* bad: requires the complete implementation of contacts, calendars and tasks in our own stack, as none of those services are provided by IMAP/SMTP backends
|
||||
512
docs/adr/0007-groupware-webui-api.md
Normal file
512
docs/adr/0007-groupware-webui-api.md
Normal file
@@ -0,0 +1,512 @@
|
||||
---
|
||||
status: accepted
|
||||
date: 2025-07-22
|
||||
author: pbleser-oc
|
||||
consulted: AlexAndBear, butonic, dragotin, fschade, JammingBen, kulmann, martinherfurth, micbar, rhafer
|
||||
title: "API for the Groupware Web UI"
|
||||
---
|
||||
<!-- markdownlint-disable-file MD024 MD033 -->
|
||||
|
||||
## Context
|
||||
|
||||
We need a comprehensive HTTP API for the OpenCloud Web UI to provide access to the following (upcoming) modules and Groupware functionalities:
|
||||
|
||||
* Mail
|
||||
* Contacts
|
||||
* Calendar
|
||||
* Tasks
|
||||
* Chat
|
||||
* Configuration
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
subgraph clients
|
||||
ui(OpenCloud UI)
|
||||
muas(Other<br>MUAs)
|
||||
end
|
||||
subgraph Backend
|
||||
subgraph OpenCloud
|
||||
direction TB
|
||||
groupware("OpenCloud<br>Groupware")
|
||||
drive("OpenCloud<br>Drive")
|
||||
end
|
||||
stalwart(Stalwart)
|
||||
end
|
||||
subgraph Storage
|
||||
drive_storage[(drive<br>storage)]
|
||||
stalwart_metadata[(metadata<br>storage)]
|
||||
stalwart_storage[(object<br>storage)]
|
||||
end
|
||||
ui x@==>|?|groupware
|
||||
x@{ animate: true }
|
||||
ui-->|Graph|drive
|
||||
muas-->|IMAP,SMTP,*DAV|stalwart
|
||||
groupware-->drive
|
||||
groupware-->|JMAP|stalwart
|
||||
drive-->drive_storage
|
||||
stalwart-->stalwart_metadata
|
||||
stalwart-->stalwart_storage
|
||||
```
|
||||
|
||||
Additionally, the API must also be able to provide information about related resources and their relationships, as outlined in [the Resource Linking ADR](./0003-groupware-resource-linking.md).
|
||||
|
||||
For the OpenCloud Drive services, the communication between UI client and backend services is performed via the [LibreGraph API](https://github.com/opencloud-eu/libre-graph-api), which is based on [Microsoft Graph](https://developer.microsoft.com/en-us/graph). The goal of this ADR is **not** to question or change that decision, and the choice of an option is merely for the communication with the Groupware backend.
|
||||
|
||||
Communication between the OpenCloud Groupware and Stalwart will make use of the [JMAP (JSON Meta Application Protocol) protocol](https://jmap.io/spec-mail.html).
|
||||
|
||||
The API for the OpenCloud Web UI is **not** supposed to be an abstraction of that and thus may use JMAP data formats.
|
||||
|
||||
Other [MUAs (Mail User Agents)](https://en.wikipedia.org/wiki/Email_client) converse directly with Stalwart using [IMAP](https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol) or [POP3](https://en.wikipedia.org/wiki/Post_Office_Protocol), [SMTP](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol), [CalDAV](https://en.wikipedia.org/wiki/CalDAV), [CardDAV](https://en.wikipedia.org/wiki/CardDAV), or JMAP itself.
|
||||
|
||||
This ADR concerns the decision regarding which API approach/process/technology/specification to use, not the details of the data model and such, which will need to be fleshed out following the requirements and priorities of the OpenCloud UI Client development, regardless of the selected approach.
|
||||
|
||||
## Decision Drivers
|
||||
|
||||
### UI Driven
|
||||
|
||||
The decision must be significantly driven by the OpenCloud UI Client developers, since they are the primary consumers of the API.
|
||||
|
||||
They will also be the sole consumers for a foreseeable while until the OpenCloud Groupware UI reaches a stable feature-complete milestone, which is the earliest point in time for the APIs to be considered stable as well and potentially be consumed by third parties.
|
||||
|
||||
Backend developers are stakeholders in that aspect as well though, as the choice of API approach has an impact on the complexity, costs and maintainability of the backend services as well.
|
||||
|
||||
### Economic Awareness
|
||||
|
||||
Reduction of complexity and implementation efforts, albeit not at all costs, and not only on the short run.
|
||||
|
||||
It is obviously of advantage when an option requires less implementation, or less complexity in its implementation.
|
||||
|
||||
### Efficiency
|
||||
|
||||
Regarding efficiency, the goal is to design an API that is tailored to providing responsiveness ([pagination](https://apisyouwonthate.com/blog/api-design-basics-pagination/), [SSEs (Server-Side Events)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events), ...) and good network performance.
|
||||
|
||||
The latter is achieved by minimizing the number of roundtrips between the client and the servers, which, in turn, is typically achieved through the use of higher level APIs as opposed to a granular API that provides more flexibility but also, by its very nature, requires the combination of multiple request-response roundtrips over the wire.
|
||||
|
||||
### Third Party Consumption
|
||||
|
||||
We are assuming that the APIs are public APIs (not just technically) and may be consumed by SDKs and third parties.
|
||||
|
||||
Implications are that care must be put into providing an API that is stable, versioned, has a changelog, and potentially provided as a product with [LTS (Long-term Support)](https://en.wikipedia.org/wiki/Long-term_support) options.
|
||||
|
||||
This also hints at the necessity of a capability exchange/discovery protocol between clients and the Groupware backend, as we will have different versions of clients and servers in the wild, and they need to be able to understand each other. Crucially, if locally running clients are developed, they can go a long time without being updated.
|
||||
|
||||
## Considered Options
|
||||
|
||||
* [LibreGraph](#libregraph)
|
||||
* [JMAP](#jmap)
|
||||
* [custom REST API](#custom-rest-api) (albeit potentially based on standards, at least partially)
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
The decision was made to go with the custom REST implementation option, mainly due to
|
||||
|
||||
* the use of LibreGraph providing little benefits
|
||||
* if would provide us with a fleshed out API for groupware
|
||||
* but we would not implement it fully
|
||||
* and it is really an API for Outlook and Exchange, not a generic groupware standard
|
||||
* furthermore, a significant blocker is that it does not provide for a way to support multiple accounts for a user
|
||||
* the experience of implementing and using the LibreGraph API for the Drive components has made light of some challenges that we would not like to repeat
|
||||
* using JMAP directly
|
||||
* is a very interesting option in terms of standards, as it is an RFC,
|
||||
* but we currently see that approach as too risky as per the potential complexity of parsing payloads of JMAP commands and their backreferences, plugging those across commands that must be forwarded as-is to Stalwart and others that need to be handled by the Groupware middleware itself, but also the potential need to reverse engineer the high-level meaning of chained low-level JMAP commands in order to implement enrichment, caches, reverse indexes, etc...
|
||||
* however, it might be a better path forward in the future, especially if JMAP becomes a viable option for replacing the current use of LibreGraph as well
|
||||
|
||||
### Consequences
|
||||
|
||||
* we will need to design an API on our own, from scratch, albeit maximally making use of JMAP data structures
|
||||
* that API will need to be maintained as a product, with documentation, versioning, LTS
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
* [LibreGraph](#proscons-libregraph)
|
||||
* [JMAP](#proscons-jmap)
|
||||
* [Custom REST API](#proscons-custom)
|
||||
|
||||
### <a id="proscons-libregraph"/>LibreGraph
|
||||
|
||||
[LibreGraph](https://github.com/opencloud-eu/libre-graph-api) is an API specification that is heavily inspired by and based on [Microsoft Graph](https://developer.microsoft.com/en-us/graph), of which it is a partial implementation, but also with modifications where necessary.
|
||||
|
||||
Example:
|
||||
|
||||
```text
|
||||
GET /v1.0/me/messages?$select=sender,subject&$count=50&$orderby=received
|
||||
```
|
||||
|
||||
#### Good
|
||||
|
||||
* is already in use as the API for OpenCloud Drive operations, with a small stack to use it in the OpenCloud Web UI
|
||||
* provides an API and data model that has already been thought out and used in production (albeit with only few different implementations)
|
||||
|
||||
#### Neutral
|
||||
|
||||
* does not have to follow the Microsoft Graph API, can be customized to our own needs, but in which case it becomes doubtful that there is any benefit in mimicking the Graph API in the first place if we diverge from it
|
||||
* there is no compatibility benefit
|
||||
* the only MUA that uses the Microsoft Graph API is Microsoft Outlook, and it is not a goal to support Microsoft Outlook as a MUA beyond standard IMAP/SMTP/CalDAV/CardDAV services (and that would be Microsoft Graph, not LibreGraph nor any customizations we would require)
|
||||
* we will not implement all of the Microsoft Graph API
|
||||
* we will not implement parts of the Microsoft Graph API as-is either, but will require to make modifications
|
||||
* if there is a requirement for considering that API as a public API for third party integrators, then the API also needs to be documented, maintained, versioned, and kept stable as much as possible (this is neutral because it is a requirement that exists with every option)
|
||||
|
||||
#### Bad
|
||||
|
||||
* not an easy API to implement
|
||||
* although we have libraries that take care of some of the more complex parts, such as parsing [OData](https://www.odata.org/) expressions
|
||||
* really only easy to use when backed by a relational database and an object relational mapping framework using [ASP.NET](https://dotnet.microsoft.com/en-us/apps/aspnet) or [JPA](https://en.wikipedia.org/wiki/Jakarta_Persistence)/[Hibernate](https://hibernate.org/)
|
||||
* its data model and peculiar interpretation of REST are really not [idomatic](https://en.wikipedia.org/wiki/HATEOAS) at all, and are clearly the result of reverse engineering the capabilities of Microsoft SQL Server and Exchange into a "standard" from the back, and then Microsoft Outlook's features and capabilities from the front
|
||||
* not tailored to our needs
|
||||
* we will most probably have a lot of cases in which we have to twist the Graph API to express what the UI needs
|
||||
* will require using complex filters, which then require complex parsing in the backend in order to translate them into JMAP
|
||||
* as opposed to directly using an expressive and maximally matching API in the first place
|
||||
* we are likely to encounter use-cases that are not covered by the Graph API (especially due to our resource linking approach)
|
||||
* does not support multiple accounts per user
|
||||
* would require the addition of an account parameter, as a query parameter or as part of the path, which would make every URL in the API incompatible with Microsoft Graph
|
||||
* more implementation effort than JMAP
|
||||
* the JMAP RFCs already provides a data model, and we would end up converting between them all the time, with incompatibilities (Graph has attributes JMAP doesn't, and the other way around)
|
||||
* possibly (probably?) more implementation effort than a custom REST API, due to its complexity
|
||||
|
||||
#### Decision Drivers
|
||||
|
||||
* UI Driven
|
||||
* some members the OpenCloud Web Team strongly prefers not to use LibreGraph due to its complexity and to the fact that we would have to reftrofit operations into an existing API that was designed by a third party
|
||||
* one upside is that there is already a client stack for performing LibreGraph operations, which could be reused to some degree for the Groupware APIs as well; it does not amount to all that much code though
|
||||
* Economic Awareness
|
||||
* more complexity and more effort as the other options due to the inherent complexity of the specification
|
||||
* a data model is already specified in full, which might save us some time on that front
|
||||
* although probably not really either since the actual data model we will work with on the backend is prescribed by JMAP, and we will only be looking to map attributes betsween JMAP and LibreGraph
|
||||
* the data model is not necessarily thorougly documented either, which will leave room for interpretation, also due to incompatibilities between JMAP and Graph
|
||||
* there will be attributes that are defined in JMAP and that we will receive from Stalwart that will not have a corresponding attribute in Graph (or be a list of values as opposed to a single value), and those will require to either lose some data by squashing it into the Graph data model, or extending the Graph data model which renders us incompatible with it
|
||||
* Efficiency
|
||||
* since the API is not tailored to our needs, we are much more likely to end up performing multiple roundtrips for single high level operations
|
||||
* Third Party Consumption
|
||||
* for some of the operations, we could point to the Microsoft Graph documentation, although that would not make for a great experience either, we would probably need to replicate it
|
||||
* our deviations and extensions will have to be maintained just like the other options
|
||||
* LibreGraph doesn't help with API stability either since
|
||||
* we don't implement all of it, and need to document what we implement and what we don't,
|
||||
* won't be compatible either due to modifications (additional parameters, unsupported parameters, different interpretations),
|
||||
* and will just as equally need to evolve it as the other options, requiring the documentation of changes as well
|
||||
* will be required to be maintained as a public API
|
||||
* documentation
|
||||
* LTS
|
||||
* versioning
|
||||
|
||||
### <a id="proscons-jmap"/>JMAP
|
||||
|
||||
[JMAP (JSON Meta Application Protocol)](https://jmap.io/spec.html) is a set of specifications that are codified in RFCs:
|
||||
|
||||
* [RFC 8620](https://tools.ietf.org/html/rfc8620): core JMAP protocol
|
||||
* [RFC 8261](https://tools.ietf.org/html/rfc8621): JMAP Mail
|
||||
* [RFC 8887](https://www.rfc-editor.org/rfc/rfc8887.html): JMAP subprotocol for WebSocket
|
||||
* [RFC 9404](https://www.rfc-editor.org/rfc/rfc9404.html): JMAP Blob Management Extension
|
||||
* [RFC 9425](https://www.rfc-editor.org/rfc/rfc9425.html): JMAP Quotas
|
||||
* [RFC 9553](https://www.rfc-editor.org/rfc/rfc9553.html): uses JSContact
|
||||
* [RFC 8984](https://www.rfc-editor.org/rfc/rfc8984.html): uses JSCalendar
|
||||
|
||||
of which some are still in development at the time of writing:
|
||||
|
||||
* [JMAP Contacts](https://jmap.io/spec-contacts.html)
|
||||
* [JMAP Calendars](https://jmap.io/spec-calendars.html)
|
||||
* [JMAP Sharing](https://jmap.io/spec-sharing.html)
|
||||
* [JMAP Tasks](https://jmap.io/spec-tasks.html)
|
||||
|
||||
To exemplify the JMAP protocol, the following code block is a JMAP request that
|
||||
|
||||
* fetches the 30 last received emails from a mailbox (folder)
|
||||
* the threads of those emails
|
||||
* email metadata of all of those threads, including a preview
|
||||
|
||||
<details open>
|
||||
<summary>Click here to toggle the display of this example.</summary>
|
||||
|
||||
```json
|
||||
[[ "Email/query", {
|
||||
"accountId": "ue150411c",
|
||||
"filter": {
|
||||
"inMailbox": "fb666a55"
|
||||
},
|
||||
"sort": [{
|
||||
"isAscending": false,
|
||||
"property": "receivedAt"
|
||||
}],
|
||||
"collapseThreads": true,
|
||||
"position": 0,
|
||||
"limit": 30,
|
||||
"calculateTotal": true
|
||||
}, "0" ],
|
||||
[ "Email/get", {
|
||||
"accountId": "ue150411c",
|
||||
"#ids": {
|
||||
"resultOf": "0",
|
||||
"name": "Email/query",
|
||||
"path": "/ids"
|
||||
},
|
||||
"properties": [
|
||||
"threadId"
|
||||
]
|
||||
}, "1" ],
|
||||
[ "Thread/get", {
|
||||
"accountId": "ue150411c",
|
||||
"#ids": {
|
||||
"resultOf": "1",
|
||||
"name": "Email/get",
|
||||
"path": "/list/*/threadId"
|
||||
}
|
||||
}, "2" ],
|
||||
[ "Email/get", {
|
||||
"accountId": "ue150411c",
|
||||
"#ids": {
|
||||
"resultOf": "2",
|
||||
"name": "Thread/get",
|
||||
"path": "/list/*/emailIds"
|
||||
},
|
||||
"properties": [
|
||||
"threadId",
|
||||
"mailboxIds",
|
||||
"keywords",
|
||||
"hasAttachment",
|
||||
"from",
|
||||
"subject",
|
||||
"receivedAt",
|
||||
"size",
|
||||
"preview"
|
||||
]
|
||||
}, "3" ]]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### Good
|
||||
|
||||
* flexible protocol that can easily be implemented by clients
|
||||
* potentially does not require implementation efforts on the backend side
|
||||
* would obviously support the full potential of JMAP and Stalwart
|
||||
* we could potentially extend JMAP with our own data models and operations based on the [JMAP Core Protocol](https://jmap.io/spec-core.html), possibly even propose them as RFCs
|
||||
* we can start with JMAP request objects that contain only a few or even only one JMAP methods (indicated by the [maxCallsInRequest capability](https://datatracker.ietf.org/doc/html/rfc8620#section-2)), allowing more calls as we need
|
||||
* clients could implement the funtionality they need using multiple requests in the beginning, then we implement missing functionality on the server
|
||||
* this would allow us to speed up requests that we need while at the same time giving clients the ability to make any necessary individual calls
|
||||
* probably only a partially useful approach since chaining JMAP requests is necessary for even the most mundane operations, to avoid the inefficiency of multiple roundtrips
|
||||
|
||||
#### Neutral
|
||||
|
||||
* the [existing JMAP specifications](https://jmap.io/spec.html) will not cover 100% of the Web UI API needs (e.g. configuration settings[^config], [resource linking](./0003-groupware-resource-linking.md), ...), but that does not prevent us from implementing additional custom APIs, either as non-JMAP REST APIs, or as extensions of JMAP
|
||||
* we would need to gauge whether JMAP communication
|
||||
* should occur directly between the OpenCloud UI and Stalwart,
|
||||
* or whether an OpenCloud Groupware service should be used as an intermediary and as an [anti-corruption layer](https://ddd-practitioners.com/home/glossary/bounded-context/bounded-context-relationship/anticorruption-layer/)
|
||||
* if there is a requirement for considering that API as a public API for third party integrators, then the API also needs to be documented, maintained, versioned, and kept stable as much as possible (this is neutral because it is a requirement that exists with every option)
|
||||
|
||||
[^config]: although Stalwart will most likely have a [JMAP API for application configuration settings as well](https://matrix.to/#/!blIcSTIPwfKMtOEWcg:matrix.org/$CD9C6IZN28bbmN0Arb_Y-RapgsS4XqAqnDgf15yJahM?via=matrix.org&via=mozilla.org&via=chat.opencloud.eu)
|
||||
> Message from [Mauro](https://github.com/mdecimus):
|
||||
>
|
||||
> Hi everyone, I'm curious what you think about standardizing a simple protocol/extension for users to easily manage certain account settings directly from their email clients. For instance, such a protocol could handle:
|
||||
>
|
||||
> * Passwords, app passwords, and MFA settings
|
||||
> * Locale preferences
|
||||
> * Timezone configuration
|
||||
> * Basic email forwarding (without needing custom Sieve scripts)
|
||||
> * Vacation/auto-responses
|
||||
> * Blocking specific email addresses
|
||||
> * Spam reporting (though not strictly a setting)
|
||||
> * Calendar-related preferences
|
||||
> * Encryption-at-rest settings
|
||||
> * Mail auto-expunge policies
|
||||
> * ... and potentially more.
|
||||
>
|
||||
> My initial thought is to implement this as a JMAP extension rather than inventing another protocol similar to ManageSieve, which feels somewhat like a "Frankenstein" IMAP extension.
|
||||
>
|
||||
> Many mailbox providers already offer some or all of these settings through their web interfaces, but a standardized JMAP-based extension could let users adjust these directly within their preferred email clients or via APIs.
|
||||
|
||||
#### Bad
|
||||
|
||||
* potentially bad: most probably too flexible for its own good, as it makes it difficult to reverse-engineer the high-level meaning of a set of JMAP requests in order to capture its semantics, e.g. to implement caching or reverse indexes for performance
|
||||
* since the OpenCloud Drive backends use the LibreGraph API, using a JMAP based API for Groupware bears the risk of having multiple APIs to do the same thing, which we need to be careful about, and avoid if possible
|
||||
|
||||
> [!NOTE]
|
||||
> This seems like a mild "bad" item, but the risk risk here is significant: if it turns out that we need to capture the semantics of API requests to perform additional operations (e.g. caching or indexing for performance reasons, or to decorate the data from Stalwart with information from other services), then we would have to re-implement the whole API as JMAP is too complex to parse to extract semantics from.
|
||||
|
||||
#### Two Approaches
|
||||
|
||||
There are two approaches as to how to implement our protocol based on JMAP:
|
||||
|
||||
* either our clients must split JMAP operations and send some to Stalwart, and others to the Groupware backend (depending on which endpoint is in charge of which API)
|
||||
* or our clients send all the JMAP operations to the Groupware backend, which is then in charge to relay JMAP commands that are to be handled by Stalwart to Stalwart
|
||||
|
||||
##### Directly to Stalwart
|
||||
|
||||
If the OpenCloud UI Client communicates directly with Stalwart (using JMAP), then
|
||||
|
||||
* good: we don't need to implement any sort of "bridge" in the OpenCloud Groupware service (although the implementation effort is likely to be low)
|
||||
* good: we avoid an additional hop in the network, gaining on performance and potentially on throughput
|
||||
* bad: it will have to perform additional API requests for data and features that are not provided by Stalwart with the OpenCloud Groupware service (e.g. [Resource Linking](./0003-groupware-resource-linking.md)) as well, which is likely to lead to an increase in the number of network roundtrips
|
||||
* bad: would be unable to extend the protocol with OpenCloud Groupware specific models and data
|
||||
* bad: would be unable to implement caching or similar performance improvements if necessary
|
||||
* bad: prevents us from implementing infrastructure features that are not present in Stalwart and might never be in the way we would need them, e.g. sharding across multi-site redundancy
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
subgraph clients
|
||||
ui(OpenCloud UI)
|
||||
muas(Other<br>MUAs)
|
||||
end
|
||||
subgraph Backend
|
||||
subgraph OpenCloud
|
||||
direction TB
|
||||
groupware("OpenCloud<br>Groupware")
|
||||
drive("OpenCloud<br>Drive")
|
||||
end
|
||||
stalwart(Stalwart)
|
||||
end
|
||||
subgraph Storage
|
||||
drive_storage[(drive<br>storage)]
|
||||
stalwart_metadata[(metadata<br>storage)]
|
||||
stalwart_storage[(object<br>storage)]
|
||||
end
|
||||
ui x@==>|JMAP|stalwart
|
||||
x@{ animate: true }
|
||||
ui y@==>|JMAP or REST|groupware
|
||||
y@{ animate: true }
|
||||
ui-->|Graph|drive
|
||||
muas-->|IMAP,SMTP,*DAV|stalwart
|
||||
groupware-->drive
|
||||
groupware-->|JMAP|stalwart
|
||||
drive-->drive_storage
|
||||
stalwart-->stalwart_metadata
|
||||
stalwart-->stalwart_storage
|
||||
```
|
||||
|
||||
##### Groupware intermediary
|
||||
|
||||
Alternatively, if the OpenCloud UI Client exclusively communicates with the OpenCloud Groupware service (using JMAP), then
|
||||
|
||||
* good: the OpenCloud Groupware service acts as a anti-corruption layer, which would allow us to
|
||||
* implement caching and similar performance improvement measures if necessary (e.g. reverse indexing of costly data)
|
||||
* implement infrastructure features that are not present in Stalwart and might never be in the way we would need them, e.g. sharding across multi-site redundancy
|
||||
* extend the JMAP protocol
|
||||
* good: it enables us to minimize network roundtrips between the OpenCloud UI Client and the OpenCloud Groupware backend as there is no need to perform additional requests elsewhere
|
||||
* bad: we have an additional intermediary hop that "just" relays operations to Stalwart most of the time
|
||||
* due to Go HTTP stack limitations (lack of zero-copy asynchronous I/O),
|
||||
* that might incur a cost of "needlessly" copying data in memory
|
||||
* as well as performing blocking I/O (at the very least since JMAP requests first need to be read in full by te OpenCloud Groupware before they then can be sent to Stalwart more or less as-is, and the same applies to the responses)
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
subgraph clients
|
||||
ui(OpenCloud UI)
|
||||
muas(Other<br>MUAs)
|
||||
end
|
||||
subgraph Backend
|
||||
subgraph OpenCloud
|
||||
direction TB
|
||||
groupware("OpenCloud<br>Groupware")
|
||||
drive("OpenCloud<br>Drive")
|
||||
end
|
||||
stalwart(Stalwart)
|
||||
end
|
||||
subgraph Storage
|
||||
drive_storage[(drive<br>storage)]
|
||||
stalwart_metadata[(metadata<br>storage)]
|
||||
stalwart_storage[(object<br>storage)]
|
||||
end
|
||||
ui y@==>|JMAP|groupware
|
||||
y@{ animate: true }
|
||||
ui-->|Graph|drive
|
||||
muas-->|IMAP,SMTP,*DAV|stalwart
|
||||
groupware-->drive
|
||||
groupware-->|JMAP|stalwart
|
||||
drive-->drive_storage
|
||||
stalwart-->stalwart_metadata
|
||||
stalwart-->stalwart_storage
|
||||
```
|
||||
|
||||
#### Decision Drivers
|
||||
|
||||
* UI Driven
|
||||
* the UI team did not express any particular preference for this option, but the JMAP protocol is simple to implement on any client
|
||||
* Economic Awareness
|
||||
* there would be less of a need to develop an API, but that doesn't put much into the balance
|
||||
* developing a generic inbound JMAP command processing engine that is capable of resolving backreferences with requests that can be sent out to different backends (Stalwart, Drive, Groupware, OpenTalk, ...) seems risky in terms of complexity, also since Go doesn't have much of a [well-supported Reactive framework](https://github.com/ReactiveX/RxGo)
|
||||
* Efficiency
|
||||
* the ability of the JMAP protocol to chain multiple low-level commands provides for a very efficient way to compose higher-level operations without the need for multiple round-trips
|
||||
* Third Party Consumption
|
||||
* for some of the operations, we could point to the JMAP documentation and RFCs, although that would not make for a great experience either, we would probably need to replicate it
|
||||
* our protocol extensions will have to be maintained just like the other options
|
||||
* will be required to be maintained as a public API
|
||||
* documentation
|
||||
* LTS
|
||||
* versioning
|
||||
|
||||
### <a id="proscons-custom"/>Custom REST API
|
||||
|
||||
A custom REST API would implement the resources and semantics as they are needed by the UI, and would be strongly if not fully UI-driven.
|
||||
|
||||
The data model should remain close or equal to JMAP's, to avoid data loss by converting back and forth.
|
||||
|
||||
We might look into existing specifications for formatting JSON payloads, such as [JSON:API](https://jsonapi.org/) or partial ones such as such as [JSON-LD](https://json-ld.org/) for relationships between resources, but this is currently outside of the scope of this ADR.
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
subgraph clients
|
||||
ui(OpenCloud UI)
|
||||
muas(Other<br>MUAs)
|
||||
end
|
||||
subgraph Backend
|
||||
subgraph OpenCloud
|
||||
direction TB
|
||||
groupware("OpenCloud<br>Groupware")
|
||||
drive("OpenCloud<br>Drive")
|
||||
end
|
||||
stalwart(Stalwart)
|
||||
end
|
||||
subgraph Storage
|
||||
drive_storage[(drive<br>storage)]
|
||||
stalwart_metadata[(metadata<br>storage)]
|
||||
stalwart_storage[(object<br>storage)]
|
||||
end
|
||||
ui y@==>|REST|groupware
|
||||
y@{ animate: true }
|
||||
ui-->|Graph|drive
|
||||
muas-->|IMAP,SMTP,*DAV|stalwart
|
||||
groupware-->drive
|
||||
groupware-->|JMAP|stalwart
|
||||
drive-->drive_storage
|
||||
stalwart-->stalwart_metadata
|
||||
stalwart-->stalwart_storage
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```text
|
||||
GET /groupware/startup/1/?mails=50
|
||||
```
|
||||
|
||||
#### Good
|
||||
|
||||
* completely tailored to the needs of the OpenCloud UI
|
||||
* a higher-level API allows for easily understanding the semantic of each operation, which enables the potential for keeping track of data in order to implement reverse indexes and caching, if necessary to achieve functional or performance goals, as opposed to using a lower-level API such as JMAP which is maximally flexible and difficult to reverse-engineer the meaning of the operation and data
|
||||
* can also be tailored to the capabilities of JMAP without exposing all of its flexibility
|
||||
* provides the potential for expanding upon what JMAP provides
|
||||
* would support the full potential of JMAP and Stalwart since the API would be designed accordingly
|
||||
* allows learning how to use and cache individual JMAP method call responses, allowing to make a better decision in the future if JMAP should be used by clients
|
||||
|
||||
#### Neutral
|
||||
|
||||
* if there is a requirement for considering that API as a public API for third party integrators, then the API also needs to be documented, maintained, versioned, and kept stable as much as possible (this is neutral because it is a requirement that exists with every option)
|
||||
|
||||
#### Bad
|
||||
|
||||
* only partially follows any standards (REST, JSON, JMAP for data models)
|
||||
* requires designing the API from scratch, as opposed to using the Graph API which already prescribes one
|
||||
* although it probably makes sense to re-use the data model of JMAP, which is prescribed in RFCs, also to avoid data loss and copying things around needlessly
|
||||
* since the OpenCloud Drive backends use the LibreGraph API, using a custom REST API for Groupware bears the risk of having multiple APIs to do the same thing, which we need to be careful about, and avoid if possible
|
||||
|
||||
#### Decision Drivers
|
||||
|
||||
* UI Driven
|
||||
* favoured solution for the OpenCloud Web UI team
|
||||
* Economic Awareness
|
||||
* designing a new custom API is not much effort since it is UI requirements driven
|
||||
* maintaining a new custom API or JMAP extensions is not more effort either, since the exact same thing needs to be done with LibreGraph, as it will have numerous exceptions and will require documenting those, as well as which parts of the Microsoft Graph API are implemented and which aren't
|
||||
* Efficiency
|
||||
* the most efficient approach since it is tailored to what is actually needed for the OpenCloud UI, which will allow us to reduce the roundtrips to a minimum
|
||||
* Third Party Consumption
|
||||
* a custom API will be required to be maintained as a public API
|
||||
* documentation
|
||||
* LTS
|
||||
* versioning
|
||||
52
docs/adr/0008-configuration-settings.md
Normal file
52
docs/adr/0008-configuration-settings.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
status: proposed
|
||||
date: 2025-07-07
|
||||
author: Pascal Bleser <p.bleser@opencloud.eu>
|
||||
decision-makers:
|
||||
consulted:
|
||||
informed:
|
||||
title: "Groupware Configuration Settings"
|
||||
template: https://raw.githubusercontent.com/adr/madr/refs/tags/4.0.0/template/adr-template.md
|
||||
---
|
||||
|
||||
* Status: draft
|
||||
|
||||
## Context
|
||||
|
||||
User Preferences need to be configurable through the UI and persisted in a backend service in order to be reliably available and backed up.
|
||||
|
||||
Such configuration options have default values that need to be set on multiple levels:
|
||||
|
||||
* globally
|
||||
* by tenant
|
||||
* by sub-tenant
|
||||
* by group of users
|
||||
* by user
|
||||
|
||||
Some options might even be client-specific, e.g. differ between the OpenCloud Web UI on desktop and the OpenCloud Web UI on mobile.
|
||||
|
||||
Furthermore, some options might be enforced and may not be overridden on every level (e.g. only globally or by tenant, by not modifiable by users.)
|
||||
|
||||
Ideally, the configuration settings have an architecture that permits pluggable sources.
|
||||
|
||||
This level of necessary complexity has a few drawbacks, the primary one being that it can become difficult to find out why a user sees this or that behavior in their UI, and thus to trace down where a given configuration setting is made (globally, on tenant level, etc...). It is thus critical to include tooling that allows to debug them.
|
||||
|
||||
## Considered Options
|
||||
|
||||
TODO
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
TODO
|
||||
|
||||
### Consequences
|
||||
|
||||
TODO
|
||||
|
||||
### Confirmation
|
||||
|
||||
TODO
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
TODO
|
||||
65
go.mod
65
go.mod
@@ -7,7 +7,9 @@ require (
|
||||
github.com/CiscoM31/godata v1.0.11
|
||||
github.com/KimMachineGun/automemlimit v0.7.5
|
||||
github.com/Masterminds/semver v1.5.0
|
||||
github.com/MicahParks/jwkset v0.8.0
|
||||
github.com/MicahParks/keyfunc/v2 v2.1.0
|
||||
github.com/MicahParks/keyfunc/v3 v3.3.11
|
||||
github.com/Nerzal/gocloak/v13 v13.9.0
|
||||
github.com/bbalet/stopwords v1.0.0
|
||||
github.com/beevik/etree v1.6.0
|
||||
@@ -19,6 +21,7 @@ require (
|
||||
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
|
||||
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
|
||||
github.com/gabriel-vasile/mimetype v1.4.11
|
||||
github.com/emersion/go-imap/v2 v2.0.0-beta.5
|
||||
github.com/ggwhite/go-masker v1.1.0
|
||||
github.com/go-chi/chi/v5 v5.2.3
|
||||
github.com/go-chi/render v1.0.3
|
||||
@@ -61,10 +64,10 @@ require (
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/ginkgo/v2 v2.27.2
|
||||
github.com/onsi/gomega v1.38.2
|
||||
github.com/open-policy-agent/opa v1.11.1
|
||||
github.com/open-policy-agent/opa v1.10.1
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250724122329-41ba6b191e76
|
||||
github.com/opencloud-eu/reva/v2 v2.41.0
|
||||
github.com/opencloud-eu/reva/v2 v2.40.1
|
||||
github.com/opensearch-project/opensearch-go/v4 v4.5.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
@@ -78,18 +81,17 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af
|
||||
github.com/spf13/afero v1.15.0
|
||||
github.com/spf13/cobra v1.10.1
|
||||
github.com/spf13/pflag v1.0.10
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/test-go/testify v1.1.4
|
||||
github.com/testcontainers/testcontainers-go v0.40.0
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0
|
||||
github.com/theckman/yacspin v0.13.12
|
||||
github.com/thejerf/suture/v4 v4.0.6
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/tidwall/sjson v1.2.5
|
||||
github.com/tus/tusd/v2 v2.8.0
|
||||
github.com/unrolled/secure v1.16.0
|
||||
github.com/urfave/cli/v2 v2.27.7
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||
github.com/xhit/go-simple-mail/v2 v2.16.0
|
||||
go-micro.dev/v4 v4.11.0
|
||||
@@ -102,14 +104,14 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.38.0
|
||||
go.opentelemetry.io/otel/sdk v1.38.0
|
||||
go.opentelemetry.io/otel/trace v1.38.0
|
||||
golang.org/x/crypto v0.46.0
|
||||
golang.org/x/crypto v0.45.0
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
|
||||
golang.org/x/image v0.33.0
|
||||
golang.org/x/net v0.48.0
|
||||
golang.org/x/net v0.47.0
|
||||
golang.org/x/oauth2 v0.33.0
|
||||
golang.org/x/sync v0.19.0
|
||||
golang.org/x/term v0.38.0
|
||||
golang.org/x/text v0.32.0
|
||||
golang.org/x/sync v0.18.0
|
||||
golang.org/x/term v0.37.0
|
||||
golang.org/x/text v0.31.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8
|
||||
google.golang.org/grpc v1.77.0
|
||||
google.golang.org/protobuf v1.36.10
|
||||
@@ -138,6 +140,7 @@ require (
|
||||
github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op // indirect
|
||||
github.com/armon/go-radix v1.0.0 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bitly/go-simplejson v0.5.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.22.0 // indirect
|
||||
@@ -160,9 +163,11 @@ require (
|
||||
github.com/blevesearch/zapx/v16 v16.2.7 // indirect
|
||||
github.com/bluele/gcache v0.0.2 // indirect
|
||||
github.com/bombsimon/logrusr/v3 v3.1.0 // indirect
|
||||
github.com/brianvoe/gofakeit/v7 v7.7.3 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/ceph/go-ceph v0.36.0 // indirect
|
||||
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.3.1 // indirect
|
||||
@@ -172,7 +177,7 @@ require (
|
||||
github.com/containerd/errdefs v1.0.0 // indirect
|
||||
github.com/containerd/errdefs/pkg v0.3.0 // indirect
|
||||
github.com/containerd/log v0.1.0 // indirect
|
||||
github.com/containerd/platforms v1.0.0-rc.2 // indirect
|
||||
github.com/containerd/platforms v1.0.0-rc.1 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.6.0 // indirect
|
||||
github.com/cornelk/hashmap v1.0.8 // indirect
|
||||
@@ -194,8 +199,11 @@ require (
|
||||
github.com/docker/go-connections v0.6.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 // indirect
|
||||
github.com/ebitengine/purego v0.8.4 // indirect
|
||||
github.com/egirna/icap v0.0.0-20181108071049-d5ee18bd70bc // indirect
|
||||
github.com/emersion/go-message v0.18.1 // indirect
|
||||
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/emvi/iso-639-1 v1.1.1 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
|
||||
@@ -205,6 +213,8 @@ require (
|
||||
github.com/gdexlab/go-render v1.0.1 // indirect
|
||||
github.com/go-acme/lego/v4 v4.4.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
|
||||
github.com/go-crypt/crypt v0.4.5 // indirect
|
||||
github.com/go-crypt/x v0.4.7 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.6.2 // indirect
|
||||
github.com/go-git/go-git/v5 v5.13.2 // indirect
|
||||
@@ -225,7 +235,7 @@ require (
|
||||
github.com/go-sql-driver/mysql v1.9.3 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/go-test/deep v1.1.0 // indirect
|
||||
github.com/go-test/deep v1.1.1 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
@@ -236,8 +246,9 @@ require (
|
||||
github.com/gofrs/flock v0.13.0 // indirect
|
||||
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gomodule/redigo v1.9.3 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
@@ -245,8 +256,10 @@ require (
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
||||
github.com/google/renameio/v2 v2.0.1 // indirect
|
||||
github.com/gookit/goutil v0.7.1 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/gorilla/handlers v1.5.1 // indirect
|
||||
github.com/gorilla/schema v1.4.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-plugin v1.7.0 // indirect
|
||||
@@ -254,8 +267,10 @@ require (
|
||||
github.com/huandu/xstrings v1.5.0 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
github.com/imdario/mergo v0.3.15 // indirect
|
||||
github.com/inbucket/html2text v0.9.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/jhillyerd/enmime/v2 v2.2.0 // indirect
|
||||
github.com/jonboulle/clockwork v0.5.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/juliangruber/go-intersect v1.1.0 // indirect
|
||||
@@ -271,7 +286,7 @@ require (
|
||||
github.com/lestrrat-go/dsig-secp256k1 v1.0.0 // indirect
|
||||
github.com/lestrrat-go/httpcc v1.0.1 // indirect
|
||||
github.com/lestrrat-go/httprc/v3 v3.0.1 // indirect
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.12 // indirect
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.11 // indirect
|
||||
github.com/lestrrat-go/option v1.0.1 // indirect
|
||||
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
|
||||
github.com/libregraph/oidc-go v1.1.0 // indirect
|
||||
@@ -286,6 +301,7 @@ require (
|
||||
github.com/mattn/go-sqlite3 v1.14.32 // indirect
|
||||
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b // indirect
|
||||
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
||||
github.com/miekg/dns v1.1.57 // indirect
|
||||
github.com/mileusna/useragent v1.3.5 // indirect
|
||||
github.com/minio/crc64nvme v1.1.0 // indirect
|
||||
@@ -302,7 +318,7 @@ require (
|
||||
github.com/moby/sys/userns v0.1.0 // indirect
|
||||
github.com/moby/term v0.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/mschoch/smat v0.2.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
@@ -320,7 +336,6 @@ require (
|
||||
github.com/pablodz/inotifywaitgo v0.0.9 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/philhofer/fwd v1.2.0 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.15 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.2 // indirect
|
||||
@@ -337,11 +352,10 @@ require (
|
||||
github.com/russellhaering/goxmldsig v1.5.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/samber/lo v1.51.0 // indirect
|
||||
github.com/samber/slog-common v0.19.0 // indirect
|
||||
github.com/samber/slog-zerolog/v2 v2.9.0 // indirect
|
||||
github.com/segmentio/asm v1.2.1 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/segmentio/kafka-go v0.4.49 // indirect
|
||||
github.com/segmentio/ksuid v1.0.4 // indirect
|
||||
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
|
||||
@@ -353,12 +367,11 @@ require (
|
||||
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
|
||||
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 // indirect
|
||||
github.com/skeema/knownhosts v1.3.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784 // indirect
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/studio-b12/gowebdav v0.9.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/tchap/go-patricia/v2 v2.3.3 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
@@ -367,9 +380,8 @@ require (
|
||||
github.com/tklauser/numcpus v0.8.0 // indirect
|
||||
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 // indirect
|
||||
github.com/trustelem/zxcvbn v1.0.1 // indirect
|
||||
github.com/urfave/cli/v2 v2.27.7 // indirect
|
||||
github.com/valyala/fastjson v1.6.4 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.31 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.30 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
github.com/wk8/go-ordered-map v1.0.0 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
@@ -390,13 +402,14 @@ require (
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/mod v0.30.0 // indirect
|
||||
golang.org/x/sys v0.39.0 // indirect
|
||||
golang.org/x/mod v0.29.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
golang.org/x/tools v0.39.0 // indirect
|
||||
golang.org/x/tools v0.38.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
gopkg.in/loremipsum.v1 v1.1.2 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
sigs.k8s.io/yaml v1.6.0 // indirect
|
||||
|
||||
123
go.sum
123
go.sum
@@ -82,8 +82,12 @@ github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1
|
||||
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/MicahParks/jwkset v0.8.0 h1:jHtclI38Gibmu17XMI6+6/UB59srp58pQVxePHRK5o8=
|
||||
github.com/MicahParks/jwkset v0.8.0/go.mod h1:fVrj6TmG1aKlJEeceAz7JsXGTXEn72zP1px3us53JrA=
|
||||
github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k=
|
||||
github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k=
|
||||
github.com/MicahParks/keyfunc/v3 v3.3.11 h1:eA6wNltwdSRX2gtpTwZseBCC9nGeBkI9KxHtTyZbDbo=
|
||||
github.com/MicahParks/keyfunc/v3 v3.3.11/go.mod h1:y6Ed3dMgNKTcpxbaQHD8mmrYDUZWJAxteddA6OQj+ag=
|
||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
@@ -134,6 +138,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/aws/aws-sdk-go v1.37.27/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/bbalet/stopwords v1.0.0 h1:0TnGycCtY0zZi4ltKoOGRFIlZHv0WqpoIGUsObjztfo=
|
||||
github.com/bbalet/stopwords v1.0.0/go.mod h1:sAWrQoDMfqARGIn4s6dp7OW7ISrshUD8IP2q3KoqPjc=
|
||||
github.com/beevik/etree v1.6.0 h1:u8Kwy8pp9D9XeITj2Z0XtA5qqZEmtJtuXZRQi+j03eE=
|
||||
@@ -194,12 +200,14 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
|
||||
github.com/bombsimon/logrusr/v3 v3.1.0 h1:zORbLM943D+hDMGgyjMhSAz/iDz86ZV72qaak/CA0zQ=
|
||||
github.com/bombsimon/logrusr/v3 v3.1.0/go.mod h1:PksPPgSFEL2I52pla2glgCyyd2OqOHAnFF5E+g8Ixco=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/brianvoe/gofakeit/v7 v7.7.3 h1:RWOATEGpJ5EVg2nN8nlaEyaV/aB4d6c3GqYrbqQekss=
|
||||
github.com/brianvoe/gofakeit/v7 v7.7.3/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
|
||||
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
|
||||
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
|
||||
github.com/butonic/go-micro/v4 v4.11.1-0.20241115112658-b5d4de5ed9b3 h1:h8Z0hBv5tg/uZMKu8V47+DKWYVQg0lYP8lXDQq7uRpE=
|
||||
github.com/butonic/go-micro/v4 v4.11.1-0.20241115112658-b5d4de5ed9b3/go.mod h1:eE/tD53n3KbVrzrWxKLxdkGw45Fg1qaNLWjpJMvIUF4=
|
||||
github.com/bytecodealliance/wasmtime-go/v39 v39.0.1 h1:RibaT47yiyCRxMOj/l2cvL8cWiWBSqDXHyqsa9sGcCE=
|
||||
github.com/bytecodealliance/wasmtime-go/v39 v39.0.1/go.mod h1:miR4NYIEBXeDNamZIzpskhJ0z/p8al+lwMWylQ/ZJb4=
|
||||
github.com/bytecodealliance/wasmtime-go/v37 v37.0.0 h1:DPjdn2V3JhXHMoZ2ymRqGK+y1bDyr9wgpyYCvhjMky8=
|
||||
github.com/bytecodealliance/wasmtime-go/v37 v37.0.0/go.mod h1:Pf1l2JCTUFMnOqDIwkjzx1qfVJ09xbaXETKgRVE4jZ0=
|
||||
github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
@@ -212,6 +220,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/ceph/go-ceph v0.36.0 h1:IDE4vEF+4fmjve+CPjD1WStgfQ+Lh6vD+9PMUI712KI=
|
||||
github.com/ceph/go-ceph v0.36.0/go.mod h1:fGCbndVDLuHW7q2954d6y+tgPFOBnRLqJRe2YXyngw4=
|
||||
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a h1:MISbI8sU/PSK/ztvmWKFcI7UGb5/HQT7B+i3a2myKgI=
|
||||
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a/go.mod h1:2GxOXOlEPAMFPfp014mK1SWq8G8BN8o7/dfYqJrVGn8=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
@@ -239,8 +249,8 @@ github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151X
|
||||
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
|
||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||
github.com/containerd/platforms v1.0.0-rc.2 h1:0SPgaNZPVWGEi4grZdV8VRYQn78y+nm6acgLGv/QzE4=
|
||||
github.com/containerd/platforms v1.0.0-rc.2/go.mod h1:J71L7B+aiM5SdIEqmd9wp6THLVRzJGXfNuWCZCllLA4=
|
||||
github.com/containerd/platforms v1.0.0-rc.1 h1:83KIq4yy1erSRgOVHNk1HYdPvzdJ5CnsWaRoJX4C41E=
|
||||
github.com/containerd/platforms v1.0.0-rc.1/go.mod h1:J71L7B+aiM5SdIEqmd9wp6THLVRzJGXfNuWCZCllLA4=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-oidc/v3 v3.17.0 h1:hWBGaQfbi0iVviX4ibC7bk8OKT5qNr4klBaCHVNvehc=
|
||||
@@ -318,6 +328,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk=
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc=
|
||||
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e h1:rcHHSQqzCgvlwP0I/fQ8rQMn/MpHE5gWSLdtpxtP6KQ=
|
||||
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e/go.mod h1:Byz7q8MSzSPkouskHJhX0er2mZY/m0Vj5bMeMCkkyY4=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
@@ -329,6 +341,12 @@ github.com/egirna/icap v0.0.0-20181108071049-d5ee18bd70bc h1:6IxmRbXV8WXVkcYcTzk
|
||||
github.com/egirna/icap v0.0.0-20181108071049-d5ee18bd70bc/go.mod h1:FdVN2WHg7zOHhJ7kZQdDorfFhIfqZaHttjAzDDvAXHE=
|
||||
github.com/elazarl/goproxy v1.4.0 h1:4GyuSbFa+s26+3rmYNSuUVsx+HgPrV1bk1jXI0l9wjM=
|
||||
github.com/elazarl/goproxy v1.4.0/go.mod h1:X/5W/t+gzDyLfHW4DrMdpjqYjpXsURlBt9lpBDxZZZQ=
|
||||
github.com/emersion/go-imap/v2 v2.0.0-beta.5 h1:H3858DNmBuXyMK1++YrQIRdpKE1MwBc+ywBtg3n+0wA=
|
||||
github.com/emersion/go-imap/v2 v2.0.0-beta.5/go.mod h1:BZTFHsS1hmgBkFlHqbxGLXk2hnRqTItUgwjSSCsYNAk=
|
||||
github.com/emersion/go-message v0.18.1 h1:tfTxIoXFSFRwWaZsgnqS1DSZuGpYGzSmCZD8SK3QA2E=
|
||||
github.com/emersion/go-message v0.18.1/go.mod h1:XpJyL70LwRvq2a8rVbHXikPgKj8+aI0kGdHlg16ibYA=
|
||||
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 h1:hH4PQfOndHDlpzYfLAAfl63E8Le6F2+EL/cdhlkyRJY=
|
||||
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/emvi/iso-639-1 v1.1.1 h1:7jrl1Sqw9ZYWmCOaH+cpQotLbGr/khwlLPXlBvE8WXU=
|
||||
@@ -352,8 +370,6 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/foxcpp/go-mockdns v1.1.0 h1:jI0rD8M0wuYAxL7r/ynTrCQQq0BVqfB99Vgk7DlmewI=
|
||||
github.com/foxcpp/go-mockdns v1.1.0/go.mod h1:IhLeSFGed3mJIAXPH2aiRQB+kqz7oqu8ld2qVbOu7Wk=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
@@ -386,6 +402,10 @@ github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hH
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s=
|
||||
github.com/go-crypt/crypt v0.4.5 h1:cCR5vVejGk1kurwoGfkLxGORY+Pc9GiE7xKCpyHZ3n4=
|
||||
github.com/go-crypt/crypt v0.4.5/go.mod h1:cQijpCkqavdF52J1bE0PObWwqKKjQCHASHQ2dtLzOJs=
|
||||
github.com/go-crypt/x v0.4.7 h1:hObjW67nhq/GI1jaD7XCv5RoiVKzF46XIbULgzH71oU=
|
||||
github.com/go-crypt/x v0.4.7/go.mod h1:K3q7VmLC0U1QFAPn0SQvXjkAtu6FJuH0rN9LNqobX6k=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
|
||||
@@ -473,6 +493,7 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
|
||||
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/gobs/pretty v0.0.0-20180724170744-09732c25a95b/go.mod h1:Xo4aNUOrJnVruqWQJBtW6+bTBDTniY8yZum5rF3b5jw=
|
||||
@@ -501,6 +522,8 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
|
||||
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
@@ -511,9 +534,8 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
@@ -609,6 +631,8 @@ github.com/gophercloud/gophercloud v0.16.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075
|
||||
github.com/gophercloud/utils v0.0.0-20210216074907-f6de111f2eae/go.mod h1:wx8HMD8oQD0Ryhz6+6ykq75PJ79iPyEqYHfwZ4l7OsA=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
|
||||
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
@@ -618,6 +642,8 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS
|
||||
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
|
||||
@@ -667,6 +693,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhKWFeDesPjMj+wCHReeknARU3wqlyN4=
|
||||
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
|
||||
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
|
||||
github.com/inbucket/html2text v0.9.0 h1:ULJmVcBEMAcmLE+/rN815KG1Fx6+a4HhbUxiDiN+qks=
|
||||
github.com/inbucket/html2text v0.9.0/go.mod h1:QDaumzl+/OzlSVbNohhmg+yAy5pKjUjzCKW2BMvztKE=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
@@ -693,6 +721,8 @@ github.com/jellydator/ttlcache/v2 v2.11.1/go.mod h1:RtE5Snf0/57e+2cLWFYWCCsLas2H
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP4mnWdTY=
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jhillyerd/enmime/v2 v2.2.0 h1:Pe35MB96eZK5Q0XjlvPftOgWypQpd1gcbfJKAt7rsB8=
|
||||
github.com/jhillyerd/enmime/v2 v2.2.0/go.mod h1:SOBXlCemjhiV2DvHhAKnJiWrtJGS/Ffuw4Iy7NjBTaI=
|
||||
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
|
||||
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
@@ -777,8 +807,8 @@ github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZ
|
||||
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
|
||||
github.com/lestrrat-go/httprc/v3 v3.0.1 h1:3n7Es68YYGZb2Jf+k//llA4FTZMl3yCwIjFIk4ubevI=
|
||||
github.com/lestrrat-go/httprc/v3 v3.0.1/go.mod h1:2uAvmbXE4Xq8kAUjVrZOq1tZVYYYs5iP62Cmtru00xk=
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.12 h1:p25r68Y4KrbBdYjIsQweYxq794CtGCzcrc5dGzJIRjg=
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.12/go.mod h1:HiUSaNmMLXgZ08OmGBaPVvoZQgJVOQphSrGr5zMamS8=
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.11 h1:yEeUGNUuNjcez/Voxvr7XPTYNraSQTENJgtVTfwvG/w=
|
||||
github.com/lestrrat-go/jwx/v3 v3.0.11/go.mod h1:XSOAh2SiXm0QgRe3DulLZLyt+wUuEdFo81zuKTLcvgQ=
|
||||
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
|
||||
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
|
||||
github.com/lestrrat-go/option/v2 v2.0.0 h1:XxrcaJESE1fokHy3FpaQ/cXW8ZsIdWcdFzzLOcID3Ss=
|
||||
@@ -845,6 +875,8 @@ github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZy
|
||||
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE=
|
||||
github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE=
|
||||
github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
|
||||
@@ -898,9 +930,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8=
|
||||
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||
@@ -957,8 +988,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
|
||||
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
|
||||
github.com/open-policy-agent/opa v1.11.1 h1:4bMlG6DjRZTRAswRyF+KUCgxHu1Gsk0h9EbZ4W9REvM=
|
||||
github.com/open-policy-agent/opa v1.11.1/go.mod h1:QimuJO4T3KYxWzrmAymqlFvsIanCjKrGjmmC8GgAdgE=
|
||||
github.com/open-policy-agent/opa v1.10.1 h1:haIvxZSPky8HLjRrvQwWAjCPLg8JDFSZMbbG4yyUHgY=
|
||||
github.com/open-policy-agent/opa v1.10.1/go.mod h1:7uPI3iRpOalJ0BhK6s1JALWPU9HvaV1XeBSSMZnr/PM=
|
||||
github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a h1:Sakl76blJAaM6NxylVkgSzktjo2dS504iDotEFJsh3M=
|
||||
github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY=
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89 h1:W1ms+lP5lUUIzjRGDg93WrQfZJZCaV1ZP3KeyXi8bzY=
|
||||
@@ -967,8 +998,8 @@ github.com/opencloud-eu/inotifywaitgo v0.0.0-20251111171128-a390bae3c5e9 h1:dIft
|
||||
github.com/opencloud-eu/inotifywaitgo v0.0.0-20251111171128-a390bae3c5e9/go.mod h1:JWyDC6H+5oZRdUJUgKuaye+8Ph5hEs6HVzVoPKzWSGI=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250724122329-41ba6b191e76 h1:vD/EdfDUrv4omSFjrinT8Mvf+8D7f9g4vgQ2oiDrVUI=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250724122329-41ba6b191e76/go.mod h1:pzatilMEHZFT3qV7C/X3MqOa3NlRQuYhlRhZTL+hN6Q=
|
||||
github.com/opencloud-eu/reva/v2 v2.41.0 h1:oie8+sxcA+drREXRTqm0LmfUdy/mmaa6pA6wkdF6tF4=
|
||||
github.com/opencloud-eu/reva/v2 v2.41.0/go.mod h1:DGH08n2mvtsQLkt8o15FV6m51FwSJJGhjR8Ty+iIJww=
|
||||
github.com/opencloud-eu/reva/v2 v2.40.1 h1:QwMkbGMhwDSwfk2WxbnTpIig2BugPBaVFjWcy2DSU3U=
|
||||
github.com/opencloud-eu/reva/v2 v2.40.1/go.mod h1:DGH08n2mvtsQLkt8o15FV6m51FwSJJGhjR8Ty+iIJww=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
|
||||
@@ -992,8 +1023,6 @@ github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2D
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
|
||||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
|
||||
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
||||
@@ -1099,8 +1128,6 @@ github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK
|
||||
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
|
||||
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||
github.com/samber/slog-common v0.19.0 h1:fNcZb8B2uOLooeYwFpAlKjkQTUafdjfqKcwcC89G9YI=
|
||||
@@ -1109,8 +1136,8 @@ github.com/samber/slog-zerolog/v2 v2.9.0 h1:6LkOabJmZdNLaUWkTC3IVVA+dq7b/V0FM6lz
|
||||
github.com/samber/slog-zerolog/v2 v2.9.0/go.mod h1:gnQW9VnCfM34v2pRMUIGMsZOVbYLqY/v0Wxu6atSVGc=
|
||||
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210127161313-bd30bebeac4f/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
|
||||
github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/segmentio/kafka-go v0.4.49 h1:GJiNX1d/g+kG6ljyJEoi9++PUMdXGAxb7JGPiDCuNmk=
|
||||
github.com/segmentio/kafka-go v0.4.49/go.mod h1:Y1gn60kzLEEaW28YshXyk2+VCUKbJ3Qr6DrnT3i4+9E=
|
||||
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
|
||||
@@ -1150,8 +1177,6 @@ github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:s
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/gunit v1.0.4/go.mod h1:EH5qMBab2UclzXUcpR8b93eHsIlp9u+pDQIRp5DZNzQ=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784 h1:0jjO3HdJfOn6gYHD/ZNZh0LLMxEAqkYX7xoDPQReEgs=
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784/go.mod h1:ff/5myEGgtsAwf26goQCO905GrEm5ugEZSd6OWTsrhM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
@@ -1161,8 +1186,6 @@ github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
||||
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
|
||||
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
|
||||
@@ -1175,8 +1198,8 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
@@ -1198,16 +1221,14 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/tchap/go-patricia/v2 v2.3.3 h1:xfNEsODumaEcCcY3gI0hYPZ/PcpVv5ju6RMAhgwZDDc=
|
||||
github.com/tchap/go-patricia/v2 v2.3.3/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
|
||||
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
|
||||
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
|
||||
github.com/testcontainers/testcontainers-go v0.40.0 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU=
|
||||
github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY=
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0 h1:3TIrGk0zXyO9CG2N6APo7auwWIwAvhkwE1reISif8LM=
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.40.0/go.mod h1:VA0UCTPu+Gcs7MzdzBnSl0qDnxquuphv3ngSGdX97Xs=
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0 h1:IkJUhR8AigQxv7qHZho/OtTU6JtiSdBGVh76o175JGo=
|
||||
github.com/testcontainers/testcontainers-go/modules/opensearch v0.39.0/go.mod h1:B7AhrDmQ4QbpzA0BeWvqzaJ8vbwcdEQDzybr35sBRfw=
|
||||
github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o=
|
||||
github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
|
||||
github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRzJr4=
|
||||
@@ -1248,8 +1269,8 @@ github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXV
|
||||
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/vektah/gqlparser/v2 v2.5.31 h1:YhWGA1mfTjID7qJhd1+Vxhpk5HTgydrGU9IgkWBTJ7k=
|
||||
github.com/vektah/gqlparser/v2 v2.5.31/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts=
|
||||
github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE=
|
||||
github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo=
|
||||
github.com/vinyldns/go-vinyldns v0.0.0-20200917153823-148a5f6b8f14/go.mod h1:RWc47jtnVuQv6+lY3c768WtXCas/Xi+U5UFc5xULmYg=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||
@@ -1375,8 +1396,8 @@ golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
||||
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -1418,8 +1439,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
|
||||
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
|
||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1473,8 +1494,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
||||
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1501,8 +1522,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1586,8 +1607,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
@@ -1599,8 +1620,8 @@ golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
|
||||
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
|
||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -1615,8 +1636,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
||||
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -1679,8 +1700,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
|
||||
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
|
||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
golang.org/x/tools/godoc v0.1.0-deprecated h1:o+aZ1BOj6Hsx/GBdJO/s815sqftjSnrZZwyYTHODvtk=
|
||||
golang.org/x/tools/godoc v0.1.0-deprecated/go.mod h1:qM63CriJ961IHWmnWa9CjZnBndniPt4a3CK0PVB9bIg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1800,6 +1821,8 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/loremipsum.v1 v1.1.2 h1:12APklfJKuGszqZsrArW5QoQh03/W+qyCCjvnDuS6Tw=
|
||||
gopkg.in/loremipsum.v1 v1.1.2/go.mod h1:TuRvzFuzuejXj+odBU6Tubp/EPUyGb9wmSvHenyP2Ts=
|
||||
gopkg.in/ns1/ns1-go.v2 v2.4.4/go.mod h1:GMnKY+ZuoJ+lVLL+78uSTjwTz2jMazq6AfGKQOYhsPk=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
|
||||
1
opencloud/cmd/opencloud/.gitignore
vendored
Normal file
1
opencloud/cmd/opencloud/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/__debug_bin*
|
||||
@@ -3,7 +3,6 @@ ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG VERSION
|
||||
ARG STRING
|
||||
ARG EDITION="dev"
|
||||
|
||||
RUN apk add bash make git curl gcc musl-dev libc-dev binutils-gold inotify-tools vips-dev
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/backup"
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
@@ -13,34 +11,62 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/parser"
|
||||
decomposedbs "github.com/opencloud-eu/reva/v2/pkg/storage/fs/decomposed/blobstore"
|
||||
decomposeds3bs "github.com/opencloud-eu/reva/v2/pkg/storage/fs/decomposeds3/blobstore"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// BackupCommand is the entrypoint for the backup command
|
||||
func BackupCommand(cfg *config.Config) *cobra.Command {
|
||||
bckCmd := &cobra.Command{
|
||||
Use: "backup",
|
||||
Short: "OpenCloud backup functionality",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func BackupCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "backup",
|
||||
Usage: "OpenCloud backup functionality",
|
||||
Subcommands: []*cli.Command{
|
||||
ConsistencyCommand(cfg),
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg, true))
|
||||
},
|
||||
Action: func(_ *cli.Context) error {
|
||||
fmt.Println("Read the docs")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
bckCmd.AddCommand(ConsistencyCommand(cfg))
|
||||
return bckCmd
|
||||
}
|
||||
|
||||
// ConsistencyCommand is the entrypoint for the consistency Command
|
||||
func ConsistencyCommand(cfg *config.Config) *cobra.Command {
|
||||
consCmd := &cobra.Command{
|
||||
Use: "consistency",
|
||||
Short: "check backup consistency",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
func ConsistencyCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "consistency",
|
||||
Usage: "check backup consistency",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "basepath",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/users)",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "blobstore",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed",
|
||||
Value: "decomposed",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "fail",
|
||||
Usage: "exit with non-zero status if consistency check fails",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
basePath := c.String("basepath")
|
||||
if basePath == "" {
|
||||
fmt.Println("basepath is required")
|
||||
return cli.ShowCommandHelp(c, "consistency")
|
||||
}
|
||||
|
||||
var (
|
||||
bs backup.ListBlobstore
|
||||
err error
|
||||
)
|
||||
basePath, _ := cmd.Flags().GetString("basepath")
|
||||
blobstoreFlag, _ := cmd.Flags().GetString("blobstore")
|
||||
switch blobstoreFlag {
|
||||
switch c.String("blobstore") {
|
||||
case "decomposeds3":
|
||||
bs, err = decomposeds3bs.New(
|
||||
cfg.StorageUsers.Drivers.DecomposedS3.Endpoint,
|
||||
@@ -61,8 +87,7 @@ func ConsistencyCommand(cfg *config.Config) *cobra.Command {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
fail, _ := cmd.Flags().GetBool("fail")
|
||||
if err := backup.CheckProviderConsistency(basePath, bs, fail); err != nil {
|
||||
if err := backup.CheckProviderConsistency(basePath, bs, c.Bool("fail")); err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
@@ -70,11 +95,6 @@ func ConsistencyCommand(cfg *config.Config) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
consCmd.Flags().StringP("basepath", "p", "", "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/users)")
|
||||
_ = consCmd.MarkFlagRequired("basepath")
|
||||
consCmd.Flags().StringP("blobstore", "b", "decomposed", "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed")
|
||||
consCmd.Flags().Bool("fail", false, "exit with non-zero status if consistency check fails")
|
||||
return consCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -21,47 +21,105 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
"github.com/pkg/xattr"
|
||||
"github.com/rogpeppe/go-internal/lockedfile"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// BenchmarkCommand is the entrypoint for the benchmark commands.
|
||||
func BenchmarkCommand(cfg *config.Config) *cobra.Command {
|
||||
benchCmd := &cobra.Command{
|
||||
Use: "benchmark",
|
||||
Short: "cli tools to test low and high level performance",
|
||||
func BenchmarkCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "benchmark",
|
||||
Usage: "cli tools to test low and high level performance",
|
||||
Category: "benchmark",
|
||||
Subcommands: []*cli.Command{BenchmarkClientCommand(cfg), BenchmarkSyscallsCommand(cfg)},
|
||||
}
|
||||
benchCmd.AddCommand(BenchmarkClientCommand(cfg), BenchmarkSyscallsCommand(cfg))
|
||||
return benchCmd
|
||||
}
|
||||
|
||||
// BenchmarkClientCommand is the entrypoint for the benchmark client command.
|
||||
func BenchmarkClientCommand(cfg *config.Config) *cobra.Command {
|
||||
benchClientCmd := &cobra.Command{
|
||||
Use: "client",
|
||||
Short: "Start a client that continuously makes web requests and prints stats. The options mimic curl, but URL must be at the end.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
jobs, err := cmd.Flags().GetInt("jobs")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
insecure, _ := cmd.Flags().GetBool("insecure")
|
||||
func BenchmarkClientCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "client",
|
||||
|
||||
Usage: "Start a client that continuously makes web requests and prints stats. The options mimic curl, but URL must be at the end.",
|
||||
Flags: []cli.Flag{
|
||||
|
||||
// TODO with v3 'flag.Persistent: true' can be set to make the order of flags no longer relevant \o/
|
||||
// flags mimicing curl
|
||||
&cli.StringFlag{
|
||||
Name: "request",
|
||||
Aliases: []string{"X"},
|
||||
Value: "PROPFIND",
|
||||
Usage: "Specifies a custom request method to use when communicating with the HTTP server.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user",
|
||||
Aliases: []string{"u"},
|
||||
Value: "admin:admin",
|
||||
Usage: "Specify the user name and password to use for server authentication.",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "insecure",
|
||||
Aliases: []string{"k"},
|
||||
Usage: "Skip the TLS verification step and proceed without checking.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "data",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Sends the specified data in a request to the HTTP server.",
|
||||
// TODE support multiple data flags, support data-binary, data-raw
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "header",
|
||||
Aliases: []string{"H"},
|
||||
Usage: "Extra header to include in information sent.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rate",
|
||||
Usage: `Specify the maximum transfer frequency you allow a client to use - in number of transfer starts per time unit (sometimes called request rate).
|
||||
The request rate is provided as "N/U" where N is an integer number and U is a time unit. Supported units are 's' (second), 'm' (minute), 'h' (hour) and 'd' /(day, as in a 24 hour unit). The default time unit, if no "/U" is provided, is number of transfers per hour.`,
|
||||
},
|
||||
/*
|
||||
&cli.StringFlag{
|
||||
Name: "oauth2-bearer",
|
||||
Usage: "Specify the Bearer Token for OAUTH 2.0 server authentication.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-agent",
|
||||
Aliases: []string{"A"},
|
||||
Value: "admin:admin",
|
||||
Usage: "Specify the User-Agent string to send to the HTTP server.",
|
||||
},
|
||||
*/
|
||||
// other flags
|
||||
&cli.StringFlag{
|
||||
Name: "bearer-token-command",
|
||||
Usage: "Command to execute for a bearer token, e.g. 'oidc-token opencloud'. When set, disables basic auth.",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "every",
|
||||
Usage: "Aggregate stats every time this amount of seconds has passed.",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "jobs",
|
||||
Aliases: []string{"j"},
|
||||
Value: 1,
|
||||
Usage: "Number of parallel clients to start.",
|
||||
},
|
||||
},
|
||||
Category: "benchmark",
|
||||
Action: func(c *cli.Context) error {
|
||||
opt := clientOptions{
|
||||
request: cmd.Flag("request").Value.String(),
|
||||
url: args[0],
|
||||
insecure: insecure,
|
||||
jobs: jobs,
|
||||
request: c.String("request"),
|
||||
url: c.Args().First(),
|
||||
insecure: c.Bool("insecure"),
|
||||
jobs: c.Int("jobs"),
|
||||
headers: make(map[string]string),
|
||||
data: []byte(cmd.Flag("data").Value.String()),
|
||||
data: []byte(c.String("data")),
|
||||
}
|
||||
if opt.url == "" {
|
||||
log.Fatal(errors.New("no URL specified"))
|
||||
}
|
||||
|
||||
headersSlice, err := cmd.Flags().GetStringSlice("headers")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, h := range headersSlice {
|
||||
for _, h := range c.StringSlice("headers") {
|
||||
parts := strings.SplitN(h, ":", 2)
|
||||
if len(parts) != 2 {
|
||||
log.Fatal(errors.New("invalid header '" + h + "'"))
|
||||
@@ -69,7 +127,7 @@ func BenchmarkClientCommand(cfg *config.Config) *cobra.Command {
|
||||
opt.headers[parts[0]] = strings.TrimSpace(parts[1])
|
||||
}
|
||||
|
||||
rate, _ := cmd.Flags().GetString("rate")
|
||||
rate := c.String("rate")
|
||||
if rate != "" {
|
||||
parts := strings.SplitN(rate, "/", 2)
|
||||
num, err := strconv.Atoi(parts[0])
|
||||
@@ -92,12 +150,12 @@ func BenchmarkClientCommand(cfg *config.Config) *cobra.Command {
|
||||
opt.rateDelay = unit / time.Duration(num)
|
||||
}
|
||||
|
||||
user, _ := cmd.Flags().GetString("user")
|
||||
user := c.String("user")
|
||||
opt.auth = func() string {
|
||||
return "Basic " + base64.StdEncoding.EncodeToString([]byte(user))
|
||||
}
|
||||
|
||||
btc, _ := cmd.Flags().GetString("bearer-token-command")
|
||||
btc := c.String("bearer-token-command")
|
||||
if btc != "" {
|
||||
parts := strings.SplitN(btc, " ", 2)
|
||||
var cmd *exec.Cmd
|
||||
@@ -115,10 +173,7 @@ func BenchmarkClientCommand(cfg *config.Config) *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
every, err := cmd.Flags().GetInt("every")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
every := c.Int("every")
|
||||
if every != 0 {
|
||||
opt.ticker = time.NewTicker(time.Second * time.Duration(every))
|
||||
defer opt.ticker.Stop()
|
||||
@@ -128,22 +183,6 @@ func BenchmarkClientCommand(cfg *config.Config) *cobra.Command {
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
// TODO with v3 'flag.Persistent: true' can be set to make the order of flags no longer relevant \o/
|
||||
// flags mimicing curl
|
||||
benchClientCmd.Flags().StringP("request", "X", "PROPFIND", "Specifies a custom request method to use when communicating with the HTTP server.")
|
||||
benchClientCmd.Flags().StringP("user", "u", "admin:admin", "Specify the user name and password to use for server authentication.")
|
||||
benchClientCmd.Flags().BoolP("insecure", "k", false, "Skip the TLS verification step and proceed without checking.")
|
||||
benchClientCmd.Flags().StringP("data", "d", "", "Sends the specified data in a request to the HTTP server.")
|
||||
benchClientCmd.Flags().StringSliceP("headers", "H", []string{}, "Extra header to include in information sent.")
|
||||
benchClientCmd.Flags().String("rate", "", "Specify the maximum transfer frequency you allow a client to use - in number of transfer starts per time unit (sometimes called request rate). The request rate is provided as \"N/U\" where N is an integer number and U is a time unit. Supported units are 's' (second), 'm' (minute), 'h' (hour) and 'd' /(day, as in a 24 hour unit). The default time unit, if no \"/U\" is provided, is number of transfers per hour.")
|
||||
|
||||
// other flags
|
||||
benchClientCmd.Flags().IntP("jobs", "j", 1, "Number of parallel clients to start. Defaults to 1.")
|
||||
benchClientCmd.Flags().Int("every", 0, "Aggregate stats every time this amount of seconds has passed.")
|
||||
benchClientCmd.Flags().String("bearer-token-command", "", "Command to execute for a bearer token, e.g. 'oidc-token opencloud'. When set, disables basic auth.")
|
||||
|
||||
return benchClientCmd
|
||||
}
|
||||
|
||||
type clientOptions struct {
|
||||
@@ -241,13 +280,25 @@ func client(o clientOptions) error {
|
||||
}
|
||||
|
||||
// BenchmarkSyscallsCommand is the entrypoint for the benchmark syscalls command.
|
||||
func BenchmarkSyscallsCommand(cfg *config.Config) *cobra.Command {
|
||||
benchSysCallCmd := &cobra.Command{
|
||||
Use: "syscalls",
|
||||
Short: "test the performance of syscalls",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
func BenchmarkSyscallsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "syscalls",
|
||||
Usage: "test the performance of syscalls",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "path",
|
||||
Usage: "Path to test",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "iterations",
|
||||
Value: "100",
|
||||
Usage: "Number of iterations to execute",
|
||||
},
|
||||
},
|
||||
Category: "benchmark",
|
||||
Action: func(c *cli.Context) error {
|
||||
|
||||
path, _ := cmd.Flags().GetString("path")
|
||||
path := c.String("path")
|
||||
if path == "" {
|
||||
f, err := os.CreateTemp("", "opencloud-bench-temp-")
|
||||
if err != nil {
|
||||
@@ -258,16 +309,11 @@ func BenchmarkSyscallsCommand(cfg *config.Config) *cobra.Command {
|
||||
defer os.Remove(path)
|
||||
}
|
||||
|
||||
iterations, err := cmd.Flags().GetInt("iterations")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iterations := c.Int("iterations")
|
||||
|
||||
return benchmark(iterations, path)
|
||||
},
|
||||
}
|
||||
benchSysCallCmd.Flags().String("path", "", "Path to test")
|
||||
benchSysCallCmd.Flags().Int("iterations", 100, "Number of iterations to execute")
|
||||
return benchSysCallCmd
|
||||
}
|
||||
|
||||
func benchmark(iterations int, path string) error {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package command
|
||||
|
||||
const (
|
||||
CommandGroupServer = "Server"
|
||||
CommandGroupServices = "Service"
|
||||
CommandGroupStorage = "Storage"
|
||||
)
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
revactx "github.com/opencloud-eu/reva/v2/pkg/ctx"
|
||||
@@ -23,57 +25,69 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/tree"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storagespace"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/store"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// DecomposedfsCommand is the entrypoint for the groups command.
|
||||
func DecomposedfsCommand(cfg *config.Config) *cobra.Command {
|
||||
decomposedCmd := &cobra.Command{
|
||||
Use: "decomposedfs",
|
||||
Short: `cli tools to inspect and manipulate a decomposedfs storage.`,
|
||||
GroupID: CommandGroupStorage,
|
||||
func DecomposedfsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "decomposedfs",
|
||||
Usage: `cli tools to inspect and manipulate a decomposedfs storage.`,
|
||||
Category: "maintenance",
|
||||
Subcommands: []*cli.Command{
|
||||
metadataCmd(cfg),
|
||||
checkCmd(cfg),
|
||||
},
|
||||
}
|
||||
decomposedCmd.AddCommand(metadataCmd(cfg), checkCmd(cfg))
|
||||
return decomposedCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
register.AddCommand(DecomposedfsCommand)
|
||||
}
|
||||
|
||||
func checkCmd(_ *config.Config) *cobra.Command {
|
||||
cCmd := &cobra.Command{
|
||||
Use: "check-treesize",
|
||||
Short: `cli tool to check the treesize metadata of a Space`,
|
||||
RunE: check,
|
||||
func checkCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "check-treesize",
|
||||
Usage: `cli tool to check the treesize metadata of a Space`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "root",
|
||||
Aliases: []string{"r"},
|
||||
Required: true,
|
||||
Usage: "Path to the root directory of the decomposedfs",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "node",
|
||||
Required: true,
|
||||
Aliases: []string{"n"},
|
||||
Usage: "Space ID of the Space to inspect",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "repair",
|
||||
Usage: "Try to repair nodes with incorrect treesize metadata. IMPORTANT: Only use this while OpenCloud is not running.",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "Do not prompt for confirmation when running in repair mode.",
|
||||
},
|
||||
},
|
||||
Action: check,
|
||||
}
|
||||
cCmd.Flags().StringP("root", "r", "", "Path to the root directory of the decomposedfs")
|
||||
_ = cCmd.MarkFlagRequired("root")
|
||||
cCmd.Flags().StringP("node", "n", "", "Space ID of the Space to inspect")
|
||||
_ = cCmd.MarkFlagRequired("node")
|
||||
cCmd.Flags().Bool("repair", false, "Try to repair nodes with incorrect treesize metadata. IMPORTANT: Only use this while OpenCloud is not running.")
|
||||
cCmd.Flags().Bool("force", false, "Do not prompt for confirmation when running in repair mode.")
|
||||
|
||||
return cCmd
|
||||
}
|
||||
|
||||
func check(cmd *cobra.Command, args []string) error {
|
||||
rootFlag, _ := cmd.Flags().GetString("root")
|
||||
repairFlag, _ := cmd.Flags().GetBool("repair")
|
||||
forceFlag, _ := cmd.Flags().GetBool("force")
|
||||
func check(c *cli.Context) error {
|
||||
rootFlag := c.String("root")
|
||||
repairFlag := c.Bool("repair")
|
||||
|
||||
if repairFlag && !forceFlag {
|
||||
if repairFlag && !c.Bool("force") {
|
||||
answer := strings.ToLower(stringPrompt("IMPORTANT: Only use '--repair' when OpenCloud is not running. Do you want to continue? [yes | no = default]"))
|
||||
if answer != "yes" && answer != "y" {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
lu, backend := getBackend(cmd)
|
||||
lu, backend := getBackend(c)
|
||||
o := &options.Options{
|
||||
MetadataBackend: backend.Name(),
|
||||
MaxConcurrency: 100,
|
||||
@@ -86,7 +100,7 @@ func check(cmd *cobra.Command, args []string) error {
|
||||
|
||||
tree := tree.New(lu, bs, o, permissions.Permissions{}, store.Create(), &zerolog.Logger{})
|
||||
|
||||
nId, _ := cmd.Flags().GetString("node")
|
||||
nId := c.String("node")
|
||||
n, err := lu.NodeFromSpaceID(context.Background(), nId)
|
||||
if err != nil || !n.Exists {
|
||||
fmt.Println("Can not find node '" + nId + "'")
|
||||
@@ -102,10 +116,7 @@ func check(cmd *cobra.Command, args []string) error {
|
||||
})
|
||||
|
||||
treeSize, err := walkTree(ctx, tree, lu, n, repairFlag)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to walk tree of node %s: %s\n", n.ID, err)
|
||||
}
|
||||
treesizeFromMetadata, err := n.GetTreeSize(cmd.Context())
|
||||
treesizeFromMetadata, err := n.GetTreeSize(c.Context)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to read treesize of node: %s: %s\n", n.ID, err)
|
||||
}
|
||||
@@ -115,7 +126,7 @@ func check(cmd *cobra.Command, args []string) error {
|
||||
if repairFlag {
|
||||
fmt.Printf("Fixing tree size for node: %s. Calculated treesize: %d\n",
|
||||
n.ID, treeSize)
|
||||
n.SetTreeSize(cmd.Context(), treeSize)
|
||||
n.SetTreeSize(c.Context, treeSize)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -174,79 +185,105 @@ func walkTree(ctx context.Context, tree *tree.Tree, lu *lookup.Lookup, root *nod
|
||||
return treesize, nil
|
||||
}
|
||||
|
||||
func metadataCmd(cfg *config.Config) *cobra.Command {
|
||||
metaCmd := &cobra.Command{
|
||||
Use: "metadata",
|
||||
Short: `cli tools to inspect and manipulate node metadata`,
|
||||
func metadataCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "metadata",
|
||||
Usage: `cli tools to inspect and manipulate node metadata`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "root",
|
||||
Aliases: []string{"r"},
|
||||
Required: true,
|
||||
Usage: "Path to the decomposedfs",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "node",
|
||||
Required: true,
|
||||
Aliases: []string{"n"},
|
||||
Usage: "Path to or ID of the node to inspect",
|
||||
},
|
||||
},
|
||||
Subcommands: []*cli.Command{dumpCmd(cfg), getCmd(cfg), setCmd(cfg)},
|
||||
}
|
||||
metaCmd.AddCommand(dumpCmd(cfg), getCmd(cfg), setCmd(cfg))
|
||||
metaCmd.Flags().StringP("root", "r", "", "Path to the root directory of the decomposedfs")
|
||||
_ = metaCmd.MarkFlagRequired("root")
|
||||
metaCmd.Flags().StringP("node", "n", "", "Path to or ID of the node to inspect")
|
||||
_ = metaCmd.MarkFlagRequired("node")
|
||||
return metaCmd
|
||||
}
|
||||
|
||||
func dumpCmd(_ *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "dump",
|
||||
Short: `print the metadata of the given node. String attributes will be enclosed in quotes. Binary attributes will be returned encoded as base64 with their value being prefixed with '0s'.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lu, backend := getBackend(cmd)
|
||||
path, err := getNode(cmd, lu)
|
||||
func dumpCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "dump",
|
||||
Usage: `print the metadata of the given node. String attributes will be enclosed in quotes. Binary attributes will be returned encoded as base64 with their value being prefixed with '0s'.`,
|
||||
Action: func(c *cli.Context) error {
|
||||
lu, backend := getBackend(c)
|
||||
path, err := getNode(c, lu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
attribs, err := backend.All(cmd.Context(), path)
|
||||
attribs, err := backend.All(c.Context, path)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading attributes")
|
||||
return err
|
||||
}
|
||||
attributeFlag, _ := cmd.Flags().GetString("attribute")
|
||||
printAttribs(attribs, attributeFlag)
|
||||
printAttribs(attribs, c.String("attribute"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func getCmd(_ *config.Config) *cobra.Command {
|
||||
gCmd := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: `print a specific attribute of the given node. String attributes will be enclosed in quotes. Binary attributes will be returned encoded as base64 with their value being prefixed with '0s'.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lu, backend := getBackend(cmd)
|
||||
path, err := getNode(cmd, lu)
|
||||
func getCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "get",
|
||||
Usage: `print a specific attribute of the given node. String attributes will be enclosed in quotes. Binary attributes will be returned encoded as base64 with their value being prefixed with '0s'.`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "attribute",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "attribute to inspect",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
lu, backend := getBackend(c)
|
||||
path, err := getNode(c, lu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
attribs, err := backend.All(cmd.Context(), path)
|
||||
attribs, err := backend.All(c.Context, path)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading attributes")
|
||||
return err
|
||||
}
|
||||
attributeFlag, _ := cmd.Flags().GetString("attribute")
|
||||
printAttribs(attribs, attributeFlag)
|
||||
printAttribs(attribs, c.String("attribute"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
gCmd.Flags().StringP("attribute", "a", "", "attribute to inspect, can be a glob pattern (e.g. 'user.*' will match all attributes starting with 'user.').")
|
||||
return gCmd
|
||||
}
|
||||
|
||||
func setCmd(_ *config.Config) *cobra.Command {
|
||||
sCmd := &cobra.Command{
|
||||
Use: "set",
|
||||
Short: `manipulate metadata of the given node. Binary attributes can be given hex encoded (prefix by '0x') or base64 encoded (prefix by '0s').`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lu, backend := getBackend(cmd)
|
||||
n, err := getNode(cmd, lu)
|
||||
func setCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "set",
|
||||
Usage: `manipulate metadata of the given node. Binary attributes can be given hex encoded (prefix by '0x') or base64 encoded (prefix by '0s').`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "attribute",
|
||||
Required: true,
|
||||
Aliases: []string{"a"},
|
||||
Usage: "attribute to inspect",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "value",
|
||||
Required: true,
|
||||
Aliases: []string{"v"},
|
||||
Usage: "value to set",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
lu, backend := getBackend(c)
|
||||
n, err := getNode(c, lu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v, _ := cmd.Flags().GetString("value")
|
||||
v := c.String("value")
|
||||
if strings.HasPrefix(v, "0s") {
|
||||
b64, err := base64.StdEncoding.DecodeString(v[2:])
|
||||
if err == nil {
|
||||
@@ -263,8 +300,7 @@ func setCmd(_ *config.Config) *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
attributeFlag, _ := cmd.Flags().GetString("attribute")
|
||||
err = backend.Set(cmd.Context(), n, attributeFlag, []byte(v))
|
||||
err = backend.Set(c.Context, n, c.String("attribute"), []byte(v))
|
||||
if err != nil {
|
||||
fmt.Println("Error setting attribute")
|
||||
return err
|
||||
@@ -272,16 +308,9 @@ func setCmd(_ *config.Config) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
sCmd.Flags().StringP("attribute", "a", "", "attribute to inspect, can be a glob pattern (e.g. 'user.*' will match all attributes starting with 'user.').")
|
||||
_ = sCmd.MarkFlagRequired("attribute")
|
||||
|
||||
sCmd.Flags().StringP("value", "v", "", "value to set")
|
||||
_ = sCmd.MarkFlagRequired("value")
|
||||
|
||||
return sCmd
|
||||
}
|
||||
|
||||
func backend(backend string) metadata.Backend {
|
||||
func backend(root, backend string) metadata.Backend {
|
||||
switch backend {
|
||||
case "xattrs":
|
||||
return metadata.NewXattrsBackend(cache.Config{})
|
||||
@@ -291,11 +320,11 @@ func backend(backend string) metadata.Backend {
|
||||
return metadata.NullBackend{}
|
||||
}
|
||||
|
||||
func getBackend(cmd *cobra.Command) (*lookup.Lookup, metadata.Backend) {
|
||||
rootFlag, _ := cmd.Flags().GetString("root")
|
||||
func getBackend(c *cli.Context) (*lookup.Lookup, metadata.Backend) {
|
||||
rootFlag := c.String("root")
|
||||
|
||||
bod := lookup.DetectBackendOnDisk(rootFlag)
|
||||
backend := backend(bod)
|
||||
backend := backend(rootFlag, bod)
|
||||
lu := lookup.New(backend, &options.Options{
|
||||
Root: rootFlag,
|
||||
MetadataBackend: bod,
|
||||
@@ -303,8 +332,8 @@ func getBackend(cmd *cobra.Command) (*lookup.Lookup, metadata.Backend) {
|
||||
return lu, backend
|
||||
}
|
||||
|
||||
func getNode(cmd *cobra.Command, lu *lookup.Lookup) (*node.Node, error) {
|
||||
nodeFlag, _ := cmd.Flags().GetString("node")
|
||||
func getNode(c *cli.Context, lu *lookup.Lookup) (*node.Node, error) {
|
||||
nodeFlag := c.String("node")
|
||||
|
||||
id, err := storagespace.ParseID(nodeFlag)
|
||||
if err != nil {
|
||||
|
||||
9
opencloud/pkg/command/helper/common.go
Normal file
9
opencloud/pkg/command/helper/common.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package helper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func SubcommandDescription(serviceName string) string {
|
||||
return fmt.Sprintf("%s service commands", serviceName)
|
||||
}
|
||||
@@ -11,19 +11,49 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/defaults"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
cli "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// InitCommand is the entrypoint for the init command
|
||||
func InitCommand(_ *config.Config) *cobra.Command {
|
||||
initCmd := &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "initialise an OpenCloud config",
|
||||
GroupID: CommandGroupServer,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
insecureFlag := viper.GetString("insecure")
|
||||
func InitCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "init",
|
||||
Usage: "initialise an OpenCloud config",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "insecure",
|
||||
EnvVars: []string{"OC_INSECURE"},
|
||||
Value: "ask",
|
||||
Usage: "Allow insecure OpenCloud config",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "diff",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Show the difference between the current config and the new one",
|
||||
Value: false,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "force-overwrite",
|
||||
Aliases: []string{"f"},
|
||||
EnvVars: []string{"OC_FORCE_CONFIG_OVERWRITE"},
|
||||
Value: false,
|
||||
Usage: "Force overwrite existing config file",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config-path",
|
||||
Value: defaults.BaseConfigPath(),
|
||||
Usage: "Config path for the OpenCloud runtime",
|
||||
EnvVars: []string{"OC_CONFIG_DIR", "OC_BASE_DATA_PATH"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "admin-password",
|
||||
Aliases: []string{"ap"},
|
||||
EnvVars: []string{"ADMIN_PASSWORD", "IDM_ADMIN_PASSWORD"},
|
||||
Usage: "Set admin password instead of using a random generated one",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
insecureFlag := c.String("insecure")
|
||||
insecure := false
|
||||
if insecureFlag == "ask" {
|
||||
answer := strings.ToLower(stringPrompt("Do you want to configure OpenCloud with certificate checking disabled?\n This is not recommended for public instances! [yes | no = default]"))
|
||||
@@ -33,37 +63,13 @@ func InitCommand(_ *config.Config) *cobra.Command {
|
||||
} else if insecureFlag == strings.ToLower("true") || insecureFlag == strings.ToLower("yes") || insecureFlag == strings.ToLower("y") {
|
||||
insecure = true
|
||||
}
|
||||
forceOverwriteFlag := viper.GetBool("force-overwrite")
|
||||
diffFlag, _ := cmd.Flags().GetBool("diff")
|
||||
configPathFlag := viper.GetString("config-path")
|
||||
adminPasswordFlag := viper.GetString("admin-password")
|
||||
err := ocinit.CreateConfig(insecure, forceOverwriteFlag, diffFlag, configPathFlag, adminPasswordFlag)
|
||||
err := ocinit.CreateConfig(insecure, c.Bool("force-overwrite"), c.Bool("diff"), c.String("config-path"), c.String("admin-password"))
|
||||
if err != nil {
|
||||
log.Fatalf("Could not create config: %s", err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
initCmd.Flags().String("insecure", "ask", "Allow insecure OpenCloud config")
|
||||
_ = viper.BindEnv("insecure", "OC_INSECURE")
|
||||
_ = viper.BindPFlag("insecure", initCmd.Flags().Lookup("insecure"))
|
||||
|
||||
initCmd.Flags().BoolP("diff", "d", false, "Show the difference between the current config and the new one")
|
||||
|
||||
initCmd.Flags().BoolP("force-overwrite", "f", false, "Force overwrite existing config file")
|
||||
_ = viper.BindEnv("force-overwrite", "OC_FORCE_CONFIG_OVERWRITE")
|
||||
_ = viper.BindPFlag("force-overwrite", initCmd.Flags().Lookup("force-overwrite"))
|
||||
|
||||
initCmd.Flags().String("config-path", defaults.BaseConfigPath(), "Config path for the OpenCloud runtime")
|
||||
_ = viper.BindEnv("config-path", "OC_CONFIG_DIR")
|
||||
_ = viper.BindEnv("config-path", "OC_BASE_DATA_PATH")
|
||||
_ = viper.BindPFlag("config-path", initCmd.Flags().Lookup("config-path"))
|
||||
|
||||
initCmd.Flags().String("admin-password", "", "Set admin password instead of using a random generated one")
|
||||
_ = viper.BindEnv("admin-password", "ADMIN_PASSWORD")
|
||||
_ = viper.BindEnv("admin-password", "IDM_ADMIN_PASSWORD")
|
||||
_ = viper.BindPFlag("admin-password", initCmd.Flags().Lookup("admin-password"))
|
||||
return initCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -74,7 +80,7 @@ func stringPrompt(label string) string {
|
||||
input := ""
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
_, _ = fmt.Fprint(os.Stderr, label+" ")
|
||||
fmt.Fprint(os.Stderr, label+" ")
|
||||
input, _ = reader.ReadString('\n')
|
||||
if input != "" {
|
||||
break
|
||||
|
||||
@@ -8,26 +8,31 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/parser"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// ListCommand is the entrypoint for the list command.
|
||||
func ListCommand(cfg *config.Config) *cobra.Command {
|
||||
listCmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "list OpenCloud services running in the runtime (supervised mode)",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg, true))
|
||||
func ListCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list OpenCloud services running in the runtime (supervised mode)",
|
||||
Category: "runtime",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "hostname",
|
||||
Value: "localhost",
|
||||
EnvVars: []string{"OC_RUNTIME_HOST"},
|
||||
Destination: &cfg.Runtime.Host,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "port",
|
||||
Value: "9250",
|
||||
EnvVars: []string{"OC_RUNTIME_PORT"},
|
||||
Destination: &cfg.Runtime.Port,
|
||||
},
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
host := viper.GetString("hostname")
|
||||
port := viper.GetString("port")
|
||||
|
||||
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(host, port))
|
||||
Action: func(c *cli.Context) error {
|
||||
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Host, cfg.Runtime.Port))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to the runtime. Has the runtime been started and did you configure the right runtime address (\"%s\")", cfg.Runtime.Host+":"+cfg.Runtime.Port)
|
||||
}
|
||||
@@ -43,15 +48,6 @@ func ListCommand(cfg *config.Config) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
listCmd.Flags().String("hostname", "localhost", "hostname of the runtime")
|
||||
_ = viper.BindEnv("hostname", "OC_RUNTIME_HOST")
|
||||
_ = viper.BindPFlag("hostname", listCmd.Flags().Lookup("hostname"))
|
||||
|
||||
listCmd.Flags().String("port", "9250", "port of the runtime")
|
||||
_ = viper.BindEnv("port", "OC_RUNTIME_PORT")
|
||||
_ = viper.BindPFlag("port", listCmd.Flags().Lookup("port"))
|
||||
return listCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -10,10 +10,9 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
|
||||
"github.com/pkg/xattr"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/theckman/yacspin"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
|
||||
@@ -38,16 +37,15 @@ type EntryInfo struct {
|
||||
}
|
||||
|
||||
// PosixfsCommand is the entrypoint for the posixfs command.
|
||||
func PosixfsCommand(cfg *config.Config) *cobra.Command {
|
||||
posixCmd := &cobra.Command{
|
||||
Use: "posixfs",
|
||||
Short: `cli tools to inspect and manipulate a posixfs storage.`,
|
||||
GroupID: CommandGroupStorage,
|
||||
func PosixfsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "posixfs",
|
||||
Usage: `cli tools to inspect and manipulate a posixfs storage.`,
|
||||
Category: "maintenance",
|
||||
Subcommands: []*cli.Command{
|
||||
consistencyCmd(cfg),
|
||||
},
|
||||
}
|
||||
|
||||
posixCmd.AddCommand(consistencyCmd(cfg))
|
||||
|
||||
return posixCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -55,23 +53,27 @@ func init() {
|
||||
}
|
||||
|
||||
// consistencyCmd returns a command to check the consistency of the posixfs storage.
|
||||
func consistencyCmd(cfg *config.Config) *cobra.Command {
|
||||
consCmd := &cobra.Command{
|
||||
Use: "consistency",
|
||||
Short: "check the consistency of the posixfs storage",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return checkPosixfsConsistency(cmd, cfg)
|
||||
func consistencyCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "consistency",
|
||||
Usage: "check the consistency of the posixfs storage",
|
||||
Action: func(c *cli.Context) error {
|
||||
return checkPosixfsConsistency(c, cfg)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "root",
|
||||
Aliases: []string{"r"},
|
||||
Required: true,
|
||||
Usage: "Path to the root directory of the posixfs storage",
|
||||
},
|
||||
},
|
||||
}
|
||||
consCmd.Flags().StringP("root", "r", "", "Path to the root directory of the posixfs storage")
|
||||
_ = consCmd.MarkFlagRequired("root")
|
||||
|
||||
return consCmd
|
||||
}
|
||||
|
||||
// checkPosixfsConsistency checks the consistency of the posixfs storage.
|
||||
func checkPosixfsConsistency(cmd *cobra.Command, cfg *config.Config) error {
|
||||
rootPath, _ := cmd.Flags().GetString("root")
|
||||
func checkPosixfsConsistency(c *cli.Context, cfg *config.Config) error {
|
||||
rootPath := c.String("root")
|
||||
indexesPath := filepath.Join(rootPath, "indexes")
|
||||
|
||||
_, err := os.Stat(indexesPath)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/revisions"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
@@ -16,8 +15,7 @@ import (
|
||||
decomposeds3bs "github.com/opencloud-eu/reva/v2/pkg/storage/fs/decomposeds3/blobstore"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/lookup"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storagespace"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -26,33 +24,75 @@ var (
|
||||
)
|
||||
|
||||
// RevisionsCommand is the entrypoint for the revisions command.
|
||||
func RevisionsCommand(cfg *config.Config) *cobra.Command {
|
||||
revCmd := &cobra.Command{
|
||||
Use: "revisions",
|
||||
Short: "OpenCloud revisions functionality",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func RevisionsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "revisions",
|
||||
Usage: "OpenCloud revisions functionality",
|
||||
Subcommands: []*cli.Command{
|
||||
PurgeRevisionsCommand(cfg),
|
||||
},
|
||||
Before: func(_ *cli.Context) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg, true))
|
||||
},
|
||||
Action: func(_ *cli.Context) error {
|
||||
fmt.Println("Read the docs")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
revCmd.AddCommand(PurgeRevisionsCommand(cfg))
|
||||
|
||||
return revCmd
|
||||
}
|
||||
|
||||
// PurgeRevisionsCommand allows removing all revisions from a storage provider.
|
||||
func PurgeRevisionsCommand(cfg *config.Config) *cobra.Command {
|
||||
revCmd := &cobra.Command{
|
||||
Use: "purge",
|
||||
Short: "purge revisions",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
basePath, _ := cmd.Flags().GetString("basepath")
|
||||
func PurgeRevisionsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "purge",
|
||||
Usage: "purge revisions",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "basepath",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/metadata)",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "blobstore",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed. Note: When using decomposeds3 this needs same configuration as the storage-users service",
|
||||
Value: "decomposed",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "do not delete anything, just print what would be deleted",
|
||||
Value: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "print verbose output",
|
||||
Value: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "resource-id",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "purge all revisions of this file/space. If not set, all revisions will be purged",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "glob-mechanism",
|
||||
Usage: "the glob mechanism to find all nodes. Can be 'glob', 'list' or 'workers'. 'glob' uses globbing with a single worker. 'workers' spawns multiple go routines, accelatering the command drastically but causing high cpu and ram usage. 'list' looks for references by listing directories with multiple workers. Default is 'glob'",
|
||||
Value: "glob",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
basePath := c.String("basepath")
|
||||
if basePath == "" {
|
||||
fmt.Println("basepath is required")
|
||||
return cli.ShowCommandHelp(c, "revisions")
|
||||
}
|
||||
|
||||
var (
|
||||
bs revisions.DelBlobstore
|
||||
err error
|
||||
)
|
||||
blobstoreFlag, _ := cmd.Flags().GetString("blobstore")
|
||||
switch blobstoreFlag {
|
||||
switch c.String("blobstore") {
|
||||
case "decomposeds3":
|
||||
bs, err = decomposeds3bs.New(
|
||||
cfg.StorageUsers.Drivers.DecomposedS3.Endpoint,
|
||||
@@ -75,13 +115,12 @@ func PurgeRevisionsCommand(cfg *config.Config) *cobra.Command {
|
||||
}
|
||||
|
||||
var rid *provider.ResourceId
|
||||
resourceIDFlag, _ := cmd.Flags().GetString("resource-id")
|
||||
resid, err := storagespace.ParseID(resourceIDFlag)
|
||||
resid, err := storagespace.ParseID(c.String("resource-id"))
|
||||
if err == nil {
|
||||
rid = &resid
|
||||
}
|
||||
|
||||
mechanism, _ := cmd.Flags().GetString("glob-mechanism")
|
||||
mechanism := c.String("glob-mechanism")
|
||||
if rid.GetOpaqueId() != "" {
|
||||
mechanism = "glob"
|
||||
}
|
||||
@@ -107,30 +146,11 @@ func PurgeRevisionsCommand(cfg *config.Config) *cobra.Command {
|
||||
ch = revisions.List(p, 10)
|
||||
}
|
||||
|
||||
flagDryRun, err := cmd.Flags().GetBool("dry-run")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
flagVerbose, err := cmd.Flags().GetBool("verbose")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files, blobs, revisionResults := revisions.PurgeRevisions(ch, bs, flagDryRun, flagVerbose)
|
||||
printResults(files, blobs, revisionResults, flagDryRun)
|
||||
files, blobs, revisions := revisions.PurgeRevisions(ch, bs, c.Bool("dry-run"), c.Bool("verbose"))
|
||||
printResults(files, blobs, revisions, c.Bool("dry-run"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
revCmd.Flags().StringP("basepath", "p", "", "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/metadata)")
|
||||
_ = revCmd.MarkFlagRequired("basepath")
|
||||
revCmd.Flags().StringP("blobstore", "b", "decomposed", "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed")
|
||||
revCmd.Flags().Bool("dry-run", true, "do not delete anything, just print what would be deleted")
|
||||
revCmd.Flags().BoolP("verbose", "v", false, "print verbose output")
|
||||
revCmd.Flags().StringP("resource-id", "r", "", "purge all revisions of this file/space. If not set, all revisions will be purged")
|
||||
revCmd.Flags().String("glob-mechanism", "glob", "the glob mechanism to find all nodes. Can be 'glob', 'list' or 'workers'. 'glob' uses globbing with a single worker. 'workers' spawns multiple go routines, accelatering the command drastically but causing high cpu and ram usage. 'list' looks for references by listing directories with multiple workers. Default is 'glob'")
|
||||
|
||||
return revCmd
|
||||
}
|
||||
|
||||
func printResults(countFiles, countBlobs, countRevisions int, dryRun bool) {
|
||||
|
||||
@@ -9,32 +9,25 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/clihelper"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Execute is the entry point for the opencloud command.
|
||||
func Execute() error {
|
||||
cfg := config.DefaultConfig()
|
||||
|
||||
app := clihelper.DefaultApp(&cobra.Command{
|
||||
Use: "opencloud",
|
||||
Short: "opencloud",
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "opencloud",
|
||||
Usage: "opencloud",
|
||||
})
|
||||
|
||||
for _, commandFactory := range register.Commands {
|
||||
command := commandFactory(cfg)
|
||||
|
||||
if command.GroupID != "" && !app.ContainsGroup(command.GroupID) {
|
||||
app.AddGroup(&cobra.Group{
|
||||
ID: command.GroupID,
|
||||
Title: command.GroupID,
|
||||
})
|
||||
}
|
||||
|
||||
app.AddCommand(command)
|
||||
for _, fn := range register.Commands {
|
||||
app.Commands = append(
|
||||
app.Commands,
|
||||
fn(cfg),
|
||||
)
|
||||
}
|
||||
app.SetArgs(os.Args[1:])
|
||||
|
||||
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
return app.ExecuteContext(ctx)
|
||||
return app.RunContext(ctx, os.Args)
|
||||
}
|
||||
|
||||
@@ -6,23 +6,22 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/parser"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
func Server(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "server",
|
||||
Short: "start a fullstack server (runtime and all services in supervised mode)",
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func Server(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "server",
|
||||
Usage: "start a fullstack server (runtime and all services in supervised mode)",
|
||||
Category: "fullstack",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg, false))
|
||||
},
|
||||
GroupID: CommandGroupServer,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Action: func(c *cli.Context) error {
|
||||
// Prefer the in-memory registry as the default when running in single-binary mode
|
||||
r := runtime.New(cfg)
|
||||
return r.Start(cmd.Context())
|
||||
return r.Start(c.Context)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/command/helper"
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
appprovider "github.com/opencloud-eu/opencloud/services/app-provider/pkg/command"
|
||||
appregistry "github.com/opencloud-eu/opencloud/services/app-registry/pkg/command"
|
||||
audit "github.com/opencloud-eu/opencloud/services/audit/pkg/command"
|
||||
authapi "github.com/opencloud-eu/opencloud/services/auth-api/pkg/command"
|
||||
authapp "github.com/opencloud-eu/opencloud/services/auth-app/pkg/command"
|
||||
authbasic "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/command"
|
||||
authbearer "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/command"
|
||||
@@ -24,6 +26,7 @@ import (
|
||||
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/command"
|
||||
graph "github.com/opencloud-eu/opencloud/services/graph/pkg/command"
|
||||
groups "github.com/opencloud-eu/opencloud/services/groups/pkg/command"
|
||||
groupware "github.com/opencloud-eu/opencloud/services/groupware/pkg/command"
|
||||
idm "github.com/opencloud-eu/opencloud/services/idm/pkg/command"
|
||||
idp "github.com/opencloud-eu/opencloud/services/idp/pkg/command"
|
||||
invitations "github.com/opencloud-eu/opencloud/services/invitations/pkg/command"
|
||||
@@ -49,243 +52,248 @@ import (
|
||||
web "github.com/opencloud-eu/opencloud/services/web/pkg/command"
|
||||
webdav "github.com/opencloud-eu/opencloud/services/webdav/pkg/command"
|
||||
webfinger "github.com/opencloud-eu/opencloud/services/webfinger/pkg/command"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var serviceCommands = []register.Command{
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
var svccmds = []register.Command{
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Activitylog.Service.Name, activitylog.GetCommands(cfg.Activitylog), func(c *config.Config) {
|
||||
cfg.Activitylog.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Antivirus.Service.Name, antivirus.GetCommands(cfg.Antivirus), func(c *config.Config) {
|
||||
cfg.Antivirus.Commons = cfg.Commons
|
||||
// cfg.Antivirus.Commons = cfg.Commons // antivirus needs no commons atm
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AppProvider.Service.Name, appprovider.GetCommands(cfg.AppProvider), func(c *config.Config) {
|
||||
cfg.AppProvider.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AppRegistry.Service.Name, appregistry.GetCommands(cfg.AppRegistry), func(c *config.Config) {
|
||||
cfg.AppRegistry.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Audit.Service.Name, audit.GetCommands(cfg.Audit), func(c *config.Config) {
|
||||
cfg.Audit.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthApp.Service.Name, authapp.GetCommands(cfg.AuthApp), func(_ *config.Config) {
|
||||
cfg.AuthApp.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthBasic.Service.Name, authbasic.GetCommands(cfg.AuthBasic), func(c *config.Config) {
|
||||
cfg.AuthBasic.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthBearer.Service.Name, authbearer.GetCommands(cfg.AuthBearer), func(c *config.Config) {
|
||||
cfg.AuthBearer.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthMachine.Service.Name, authmachine.GetCommands(cfg.AuthMachine), func(c *config.Config) {
|
||||
cfg.AuthMachine.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthService.Service.Name, authservice.GetCommands(cfg.AuthService), func(c *config.Config) {
|
||||
cfg.AuthService.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Clientlog.Service.Name, clientlog.GetCommands(cfg.Clientlog), func(c *config.Config) {
|
||||
cfg.Clientlog.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Collaboration.Service.Name, collaboration.GetCommands(cfg.Collaboration), func(c *config.Config) {
|
||||
cfg.Collaboration.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.EventHistory.Service.Name, eventhistory.GetCommands(cfg.EventHistory), func(c *config.Config) {
|
||||
cfg.EventHistory.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Frontend.Service.Name, frontend.GetCommands(cfg.Frontend), func(c *config.Config) {
|
||||
cfg.Frontend.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Gateway.Service.Name, gateway.GetCommands(cfg.Gateway), func(c *config.Config) {
|
||||
cfg.Gateway.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Graph.Service.Name, graph.GetCommands(cfg.Graph), func(c *config.Config) {
|
||||
cfg.Graph.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Groups.Service.Name, groups.GetCommands(cfg.Groups), func(c *config.Config) {
|
||||
cfg.Groups.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Groupware.Service.Name, groupware.GetCommands(cfg.Groupware), func(c *config.Config) {
|
||||
cfg.Groupware.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.IDM.Service.Name, idm.GetCommands(cfg.IDM), func(c *config.Config) {
|
||||
cfg.IDM.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.IDP.Service.Name, idp.GetCommands(cfg.IDP), func(c *config.Config) {
|
||||
cfg.IDP.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Invitations.Service.Name, invitations.GetCommands(cfg.Invitations), func(c *config.Config) {
|
||||
cfg.Invitations.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Nats.Service.Name, nats.GetCommands(cfg.Nats), func(c *config.Config) {
|
||||
cfg.Nats.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Notifications.Service.Name, notifications.GetCommands(cfg.Notifications), func(c *config.Config) {
|
||||
cfg.Notifications.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.OCDav.Service.Name, ocdav.GetCommands(cfg.OCDav), func(c *config.Config) {
|
||||
cfg.OCDav.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.OCM.Service.Name, ocm.GetCommands(cfg.OCM), func(c *config.Config) {
|
||||
cfg.OCM.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.OCS.Service.Name, ocs.GetCommands(cfg.OCS), func(c *config.Config) {
|
||||
cfg.OCS.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Policies.Service.Name, policies.GetCommands(cfg.Policies), func(c *config.Config) {
|
||||
cfg.Policies.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Postprocessing.Service.Name, postprocessing.GetCommands(cfg.Postprocessing), func(c *config.Config) {
|
||||
cfg.Postprocessing.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Proxy.Service.Name, proxy.GetCommands(cfg.Proxy), func(c *config.Config) {
|
||||
cfg.Proxy.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Search.Service.Name, search.GetCommands(cfg.Search), func(c *config.Config) {
|
||||
cfg.Search.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Settings.Service.Name, settings.GetCommands(cfg.Settings), func(c *config.Config) {
|
||||
cfg.Settings.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Sharing.Service.Name, sharing.GetCommands(cfg.Sharing), func(c *config.Config) {
|
||||
cfg.Sharing.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.SSE.Service.Name, sse.GetCommands(cfg.SSE), func(c *config.Config) {
|
||||
cfg.SSE.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.StoragePublicLink.Service.Name, storagepubliclink.GetCommands(cfg.StoragePublicLink), func(c *config.Config) {
|
||||
cfg.StoragePublicLink.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.StorageShares.Service.Name, storageshares.GetCommands(cfg.StorageShares), func(c *config.Config) {
|
||||
cfg.StorageShares.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.StorageSystem.Service.Name, storagesystem.GetCommands(cfg.StorageSystem), func(c *config.Config) {
|
||||
cfg.StorageSystem.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.StorageUsers.Service.Name, storageusers.GetCommands(cfg.StorageUsers), func(c *config.Config) {
|
||||
cfg.StorageUsers.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Thumbnails.Service.Name, thumbnails.GetCommands(cfg.Thumbnails), func(c *config.Config) {
|
||||
cfg.Thumbnails.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Userlog.Service.Name, userlog.GetCommands(cfg.Userlog), func(c *config.Config) {
|
||||
cfg.Userlog.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Users.Service.Name, users.GetCommands(cfg.Users), func(c *config.Config) {
|
||||
cfg.Users.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Web.Service.Name, web.GetCommands(cfg.Web), func(c *config.Config) {
|
||||
cfg.Web.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.WebDAV.Service.Name, webdav.GetCommands(cfg.WebDAV), func(c *config.Config) {
|
||||
cfg.WebDAV.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cobra.Command {
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Webfinger.Service.Name, webfinger.GetCommands(cfg.Webfinger), func(c *config.Config) {
|
||||
cfg.Webfinger.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.AuthApi.Service.Name, authapi.GetCommands(cfg.AuthApi), func(c *config.Config) {
|
||||
cfg.AuthApi.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
// ServiceCommand composes a cobra command from the given inputs.
|
||||
func ServiceCommand(cfg *config.Config, serviceName string, subCommands []*cobra.Command, f func(*config.Config)) *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: serviceName,
|
||||
Short: fmt.Sprintf("%s service commands", serviceName),
|
||||
GroupID: CommandGroupServices,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
// ServiceCommand is the entry point for the all service commands.
|
||||
func ServiceCommand(cfg *config.Config, serviceName string, subcommands []*cli.Command, f func(*config.Config)) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: serviceName,
|
||||
Usage: helper.SubcommandDescription(serviceName),
|
||||
Category: "services",
|
||||
Before: func(c *cli.Context) error {
|
||||
configlog.Error(parser.ParseConfig(cfg, true))
|
||||
f(cfg)
|
||||
return nil
|
||||
},
|
||||
Subcommands: subcommands,
|
||||
}
|
||||
|
||||
command.AddCommand(subCommands...)
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func init() {
|
||||
for _, c := range serviceCommands {
|
||||
for _, c := range svccmds {
|
||||
register.AddCommand(c)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,13 @@ package command
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/share/manager/jsoncs3"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/share/manager/registry"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/utils"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
@@ -13,21 +19,15 @@ import (
|
||||
mregistry "github.com/opencloud-eu/opencloud/pkg/registry"
|
||||
sharing "github.com/opencloud-eu/opencloud/services/sharing/pkg/config"
|
||||
sharingparser "github.com/opencloud-eu/opencloud/services/sharing/pkg/config/parser"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/share/manager/jsoncs3"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/share/manager/registry"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/utils"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// SharesCommand is the entrypoint for the groups command.
|
||||
func SharesCommand(cfg *config.Config) *cobra.Command {
|
||||
sharesCmd := &cobra.Command{
|
||||
Use: "shares",
|
||||
Short: `cli tools to manage entries in the share manager.`,
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func SharesCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "shares",
|
||||
Usage: `cli tools to manage entries in the share manager.`,
|
||||
Category: "maintenance",
|
||||
Before: func(c *cli.Context) error {
|
||||
// Parse base config
|
||||
if err := parser.ParseConfig(cfg, true); err != nil {
|
||||
return configlog.ReturnError(err)
|
||||
@@ -37,21 +37,37 @@ func SharesCommand(cfg *config.Config) *cobra.Command {
|
||||
cfg.Sharing.Commons = cfg.Commons
|
||||
return configlog.ReturnError(sharingparser.ParseConfig(cfg.Sharing))
|
||||
},
|
||||
Subcommands: []*cli.Command{
|
||||
cleanupCmd(cfg),
|
||||
},
|
||||
}
|
||||
sharesCmd.AddCommand(cleanupCmd(cfg))
|
||||
|
||||
return sharesCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
register.AddCommand(SharesCommand)
|
||||
}
|
||||
|
||||
func cleanupCmd(cfg *config.Config) *cobra.Command {
|
||||
cleanCmd := &cobra.Command{
|
||||
Use: "cleanup",
|
||||
Short: `clean up stale entries in the share manager.`,
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func cleanupCmd(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "cleanup",
|
||||
Usage: `clean up stale entries in the share manager.`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "service-account-id",
|
||||
Value: "",
|
||||
Usage: "Name of the service account to use for the cleanup",
|
||||
EnvVars: []string{"OC_SERVICE_ACCOUNT_ID"},
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "service-account-secret",
|
||||
Value: "",
|
||||
Usage: "Secret for the service account",
|
||||
EnvVars: []string{"OC_SERVICE_ACCOUNT_SECRET"},
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
// Parse base config
|
||||
if err := parser.ParseConfig(cfg, true); err != nil {
|
||||
return configlog.ReturnError(err)
|
||||
@@ -61,24 +77,13 @@ func cleanupCmd(cfg *config.Config) *cobra.Command {
|
||||
cfg.Sharing.Commons = cfg.Commons
|
||||
return configlog.ReturnError(sharingparser.ParseConfig(cfg.Sharing))
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cleanup(cmd, cfg)
|
||||
Action: func(c *cli.Context) error {
|
||||
return cleanup(c, cfg)
|
||||
},
|
||||
}
|
||||
cleanCmd.Flags().String("service-account-id", "", "Name of the service account to use for the cleanup")
|
||||
_ = cleanCmd.MarkFlagRequired("service-account-id")
|
||||
_ = viper.BindEnv("service-account-id", "OC_SERVICE_ACCOUNT_ID")
|
||||
_ = viper.BindPFlag("service-account-id", cleanCmd.Flags().Lookup("service-account-id"))
|
||||
|
||||
cleanCmd.Flags().String("service-account-secret", "", "Secret for the service account")
|
||||
_ = cleanCmd.MarkFlagRequired("service-account-secret")
|
||||
_ = viper.BindEnv("service-account-secret", "OC_SERVICE_ACCOUNT_SECRET")
|
||||
_ = viper.BindPFlag("service-account-secret", cleanCmd.Flags().Lookup("service-account-secret"))
|
||||
|
||||
return cleanCmd
|
||||
}
|
||||
|
||||
func cleanup(_ *cobra.Command, cfg *config.Config) error {
|
||||
func cleanup(c *cli.Context, cfg *config.Config) error {
|
||||
driver := cfg.Sharing.UserSharingDriver
|
||||
// cleanup is only implemented for the jsoncs3 share manager
|
||||
if driver != "jsoncs3" {
|
||||
@@ -109,9 +114,7 @@ func cleanup(_ *cobra.Command, cfg *config.Config) error {
|
||||
return configlog.ReturnError(err)
|
||||
}
|
||||
|
||||
serviceAccountIDFlag := viper.GetString("service-account-id")
|
||||
serviceAccountSecretFlag := viper.GetString("service-account-secret")
|
||||
serviceUserCtx, err := utils.GetServiceUserContext(serviceAccountIDFlag, client, serviceAccountSecretFlag)
|
||||
serviceUserCtx, err := utils.GetServiceUserContext(c.String("service-account-id"), client, c.String("service-account-secret"))
|
||||
if err != nil {
|
||||
return configlog.ReturnError(err)
|
||||
}
|
||||
@@ -168,6 +171,39 @@ func revaShareConfig(cfg *sharing.Config) map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func revaPublicShareConfig(cfg *sharing.Config) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"json": map[string]interface{}{
|
||||
"file": cfg.PublicSharingDrivers.JSON.File,
|
||||
"gateway_addr": cfg.Reva.Address,
|
||||
},
|
||||
"jsoncs3": map[string]interface{}{
|
||||
"gateway_addr": cfg.Reva.Address,
|
||||
"provider_addr": cfg.PublicSharingDrivers.JSONCS3.ProviderAddr,
|
||||
"service_user_id": cfg.PublicSharingDrivers.JSONCS3.SystemUserID,
|
||||
"service_user_idp": cfg.PublicSharingDrivers.JSONCS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.PublicSharingDrivers.JSONCS3.SystemUserAPIKey,
|
||||
},
|
||||
"sql": map[string]interface{}{
|
||||
"db_username": cfg.PublicSharingDrivers.SQL.DBUsername,
|
||||
"db_password": cfg.PublicSharingDrivers.SQL.DBPassword,
|
||||
"db_host": cfg.PublicSharingDrivers.SQL.DBHost,
|
||||
"db_port": cfg.PublicSharingDrivers.SQL.DBPort,
|
||||
"db_name": cfg.PublicSharingDrivers.SQL.DBName,
|
||||
"password_hash_cost": cfg.PublicSharingDrivers.SQL.PasswordHashCost,
|
||||
"enable_expired_shares_cleanup": cfg.PublicSharingDrivers.SQL.EnableExpiredSharesCleanup,
|
||||
"janitor_run_interval": cfg.PublicSharingDrivers.SQL.JanitorRunInterval,
|
||||
},
|
||||
"cs3": map[string]interface{}{
|
||||
"gateway_addr": cfg.PublicSharingDrivers.CS3.ProviderAddr,
|
||||
"provider_addr": cfg.PublicSharingDrivers.CS3.ProviderAddr,
|
||||
"service_user_id": cfg.PublicSharingDrivers.CS3.SystemUserID,
|
||||
"service_user_idp": cfg.PublicSharingDrivers.CS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.PublicSharingDrivers.CS3.SystemUserAPIKey,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func logger() *zerolog.Logger {
|
||||
log := oclog.NewLogger(
|
||||
oclog.Name("migrate"),
|
||||
|
||||
@@ -3,40 +3,57 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/trash"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/parser"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func TrashCommand(cfg *config.Config) *cobra.Command {
|
||||
trashCmd := &cobra.Command{
|
||||
Use: "trash",
|
||||
Short: "OpenCloud trash functionality",
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func TrashCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "trash",
|
||||
Usage: "OpenCloud trash functionality",
|
||||
Subcommands: []*cli.Command{
|
||||
TrashPurgeEmptyDirsCommand(cfg),
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg, true))
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Action: func(_ *cli.Context) error {
|
||||
fmt.Println("Read the docs")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
trashCmd.AddCommand(TrashPurgeEmptyDirsCommand(cfg))
|
||||
|
||||
return trashCmd
|
||||
}
|
||||
|
||||
func TrashPurgeEmptyDirsCommand(cfg *config.Config) *cobra.Command {
|
||||
trashPurgeCmd := &cobra.Command{
|
||||
Use: "purge-empty-dirs",
|
||||
Short: "purge empty directories",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
basePath, _ := cmd.Flags().GetString("basepath")
|
||||
dryRun, _ := cmd.Flags().GetBool("dry-run")
|
||||
if err := trash.PurgeTrashEmptyPaths(basePath, dryRun); err != nil {
|
||||
func TrashPurgeEmptyDirsCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "purge-empty-dirs",
|
||||
Usage: "purge empty directories",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "basepath",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/users)",
|
||||
Required: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "do not delete anything, just print what would be deleted",
|
||||
Value: true,
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
basePath := c.String("basepath")
|
||||
if basePath == "" {
|
||||
fmt.Println("basepath is required")
|
||||
return cli.ShowCommandHelp(c, "trash")
|
||||
}
|
||||
|
||||
if err := trash.PurgeTrashEmptyPaths(basePath, c.Bool("dry-run")); err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
@@ -44,12 +61,6 @@ func TrashPurgeEmptyDirsCommand(cfg *config.Config) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
trashPurgeCmd.Flags().StringP("basepath", "p", "", "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/users)")
|
||||
_ = trashPurgeCmd.MarkFlagRequired("basepath")
|
||||
|
||||
trashPurgeCmd.Flags().Bool("dry-run", true, "do not delete anything, just print what would be deleted")
|
||||
|
||||
return trashPurgeCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -4,16 +4,15 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/olekukonko/tablewriter/tw"
|
||||
"github.com/urfave/cli/v2"
|
||||
mreg "go-micro.dev/v4/registry"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/pkg/registry"
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/olekukonko/tablewriter/tw"
|
||||
mreg "go-micro.dev/v4/registry"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -21,18 +20,22 @@ const (
|
||||
)
|
||||
|
||||
// VersionCommand is the entrypoint for the version command.
|
||||
func VersionCommand(cfg *config.Config) *cobra.Command {
|
||||
versionCmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "print the version of this binary and all running service instances",
|
||||
GroupID: CommandGroupServer,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
func VersionCommand(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print the version of this binary and all running service instances",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: _skipServiceListingFlagName,
|
||||
Usage: "skip service listing",
|
||||
},
|
||||
},
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("Version: " + version.GetString())
|
||||
fmt.Printf("Edition: %s\n", version.Edition)
|
||||
fmt.Printf("Compiled: %s\n", version.Compiled())
|
||||
|
||||
skipServiceListing, _ := cmd.Flags().GetBool(_skipServiceListingFlagName)
|
||||
if skipServiceListing {
|
||||
if c.Bool(_skipServiceListingFlagName) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -71,8 +74,6 @@ func VersionCommand(cfg *config.Config) *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
versionCmd.Flags().Bool(_skipServiceListingFlagName, false, "skip service listing")
|
||||
return versionCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -32,6 +32,7 @@ type OpenCloudConfig struct {
|
||||
AuthBearer AuthbearerService `yaml:"auth_bearer"`
|
||||
Users UsersAndGroupsService `yaml:"users"`
|
||||
Groups UsersAndGroupsService `yaml:"groups"`
|
||||
Groupware GroupwareService `yaml:"groupware"`
|
||||
Ocdav InsecureService `yaml:"ocdav"`
|
||||
Ocm OcmService `yaml:"ocm"`
|
||||
Thumbnails ThumbnailService `yaml:"thumbnails"`
|
||||
@@ -126,6 +127,17 @@ type GraphService struct {
|
||||
ServiceAccount ServiceAccount `yaml:"service_account"`
|
||||
}
|
||||
|
||||
// GroupwareSettings is the configuration for the groupware settings
|
||||
type GroupwareSettings struct {
|
||||
WebdavAllowInsecure bool `yaml:"webdav_allow_insecure"`
|
||||
Cs3AllowInsecure bool `yaml:"cs3_allow_insecure"`
|
||||
}
|
||||
|
||||
// GroupwareService is the configuration for the groupware service
|
||||
type GroupwareService struct {
|
||||
Groupware GroupwareSettings
|
||||
}
|
||||
|
||||
// IdmService is the configuration for the IDM service
|
||||
type IdmService struct {
|
||||
ServiceUserPasswords ServiceUserPasswordsSettings `yaml:"service_user_passwords"`
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
// Commands define the slice of commands.
|
||||
Commands []Command
|
||||
// Commands defines the slice of commands.
|
||||
Commands = []Command{}
|
||||
)
|
||||
|
||||
// Command defines the register command.
|
||||
type Command func(*config.Config) *cobra.Command
|
||||
type Command func(*config.Config) *cli.Command
|
||||
|
||||
// AddCommand appends a command to Commands.
|
||||
func AddCommand(cmd Command) {
|
||||
|
||||
@@ -2,12 +2,14 @@ package runtime
|
||||
|
||||
import (
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Options is a runtime option
|
||||
type Options struct {
|
||||
Services []string
|
||||
Logger log.Logger
|
||||
Context *cli.Context
|
||||
}
|
||||
|
||||
// Option undocumented
|
||||
@@ -19,3 +21,10 @@ func Services(s []string) Option {
|
||||
o.Services = append(o.Services, s...)
|
||||
}
|
||||
}
|
||||
|
||||
// Context option
|
||||
func Context(c *cli.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
appProvider "github.com/opencloud-eu/opencloud/services/app-provider/pkg/command"
|
||||
appRegistry "github.com/opencloud-eu/opencloud/services/app-registry/pkg/command"
|
||||
audit "github.com/opencloud-eu/opencloud/services/audit/pkg/command"
|
||||
authapi "github.com/opencloud-eu/opencloud/services/auth-api/pkg/command"
|
||||
authapp "github.com/opencloud-eu/opencloud/services/auth-app/pkg/command"
|
||||
authbasic "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/command"
|
||||
authmachine "github.com/opencloud-eu/opencloud/services/auth-machine/pkg/command"
|
||||
@@ -35,6 +36,7 @@ import (
|
||||
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/command"
|
||||
graph "github.com/opencloud-eu/opencloud/services/graph/pkg/command"
|
||||
groups "github.com/opencloud-eu/opencloud/services/groups/pkg/command"
|
||||
groupware "github.com/opencloud-eu/opencloud/services/groupware/pkg/command"
|
||||
idm "github.com/opencloud-eu/opencloud/services/idm/pkg/command"
|
||||
idp "github.com/opencloud-eu/opencloud/services/idp/pkg/command"
|
||||
invitations "github.com/opencloud-eu/opencloud/services/invitations/pkg/command"
|
||||
@@ -124,7 +126,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
|
||||
if s.Services[priority] == nil {
|
||||
s.Services[priority] = make(serviceFuncMap)
|
||||
}
|
||||
s.Services[priority][name] = NewSutureServiceBuilder(name, exec)
|
||||
s.Services[priority][name] = NewSutureServiceBuilder(exec)
|
||||
}
|
||||
|
||||
// nats is in priority group 0. It needs to start before all other services
|
||||
@@ -316,7 +318,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
|
||||
|
||||
// populate optional services
|
||||
areg := func(name string, exec func(context.Context, *occfg.Config) error) {
|
||||
s.Additional[name] = NewSutureServiceBuilder(name, exec)
|
||||
s.Additional[name] = NewSutureServiceBuilder(exec)
|
||||
}
|
||||
areg(opts.Config.Antivirus.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
|
||||
cfg.Antivirus.Context = ctx
|
||||
@@ -348,6 +350,16 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
|
||||
cfg.Notifications.Commons = cfg.Commons
|
||||
return notifications.Execute(cfg.Notifications)
|
||||
})
|
||||
areg(opts.Config.AuthApi.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
|
||||
cfg.AuthApi.Context = ctx
|
||||
cfg.AuthApi.Commons = cfg.Commons
|
||||
return authapi.Execute(cfg.AuthApi)
|
||||
})
|
||||
areg(opts.Config.Groupware.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
|
||||
cfg.Groupware.Context = ctx
|
||||
cfg.Groupware.Commons = cfg.Commons
|
||||
return groupware.Execute(cfg.Groupware)
|
||||
})
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@@ -10,17 +10,15 @@ import (
|
||||
// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree.
|
||||
type SutureService struct {
|
||||
exec func(ctx context.Context) error
|
||||
name string
|
||||
}
|
||||
|
||||
// NewSutureServiceBuilder creates a new suture service
|
||||
func NewSutureServiceBuilder(name string, f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
|
||||
func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
|
||||
return func(cfg *occfg.Config) suture.Service {
|
||||
return SutureService{
|
||||
exec: func(ctx context.Context) error {
|
||||
return f(ctx, cfg)
|
||||
},
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,8 +27,3 @@ func NewSutureServiceBuilder(name string, f func(context.Context, *occfg.Config)
|
||||
func (s SutureService) Serve(ctx context.Context) error {
|
||||
return s.exec(ctx)
|
||||
}
|
||||
|
||||
// String to fullfil fmt.Stringer interface, used to log the service name
|
||||
func (s SutureService) String() string {
|
||||
return s.name
|
||||
}
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
package clihelper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// DefaultApp is a wrapper for DefaultApp that adds Cobra specific settings
|
||||
func DefaultApp(app *cobra.Command) *cobra.Command {
|
||||
// TODO: when migration is done this has to become DefaultApp
|
||||
func DefaultApp(app *cli.App) *cli.App {
|
||||
// version info
|
||||
app.Version = fmt.Sprintf("%s (%s <%s>) (%s)", version.String, "OpenCloud GmbH", "support@opencloud.eu", version.Compiled())
|
||||
app.Version = version.String
|
||||
app.Compiled = version.Compiled()
|
||||
|
||||
// author info
|
||||
app.Authors = []*cli.Author{
|
||||
{
|
||||
Name: "OpenCloud GmbH",
|
||||
Email: "support@opencloud.eu",
|
||||
},
|
||||
}
|
||||
|
||||
// disable global version flag
|
||||
// instead we provide the version command
|
||||
app.HideVersion = true
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
appProvider "github.com/opencloud-eu/opencloud/services/app-provider/pkg/config"
|
||||
appRegistry "github.com/opencloud-eu/opencloud/services/app-registry/pkg/config"
|
||||
audit "github.com/opencloud-eu/opencloud/services/audit/pkg/config"
|
||||
authapi "github.com/opencloud-eu/opencloud/services/auth-api/pkg/config"
|
||||
authapp "github.com/opencloud-eu/opencloud/services/auth-app/pkg/config"
|
||||
authbasic "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/config"
|
||||
authbearer "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/config"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/config"
|
||||
graph "github.com/opencloud-eu/opencloud/services/graph/pkg/config"
|
||||
groups "github.com/opencloud-eu/opencloud/services/groups/pkg/config"
|
||||
groupware "github.com/opencloud-eu/opencloud/services/groupware/pkg/config"
|
||||
idm "github.com/opencloud-eu/opencloud/services/idm/pkg/config"
|
||||
idp "github.com/opencloud-eu/opencloud/services/idp/pkg/config"
|
||||
invitations "github.com/opencloud-eu/opencloud/services/invitations/pkg/config"
|
||||
@@ -100,6 +102,7 @@ type Config struct {
|
||||
Gateway *gateway.Config `yaml:"gateway"`
|
||||
Graph *graph.Config `yaml:"graph"`
|
||||
Groups *groups.Config `yaml:"groups"`
|
||||
Groupware *groupware.Config `yaml:"groupware"`
|
||||
IDM *idm.Config `yaml:"idm"`
|
||||
IDP *idp.Config `yaml:"idp"`
|
||||
Invitations *invitations.Config `yaml:"invitations"`
|
||||
@@ -125,4 +128,5 @@ type Config struct {
|
||||
WebDAV *webdav.Config `yaml:"webdav"`
|
||||
Webfinger *webfinger.Config `yaml:"webfinger"`
|
||||
Search *search.Config `yaml:"search"`
|
||||
AuthApi *authapi.Config `yaml:"authapi"`
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
appProvider "github.com/opencloud-eu/opencloud/services/app-provider/pkg/config/defaults"
|
||||
appRegistry "github.com/opencloud-eu/opencloud/services/app-registry/pkg/config/defaults"
|
||||
audit "github.com/opencloud-eu/opencloud/services/audit/pkg/config/defaults"
|
||||
authapi "github.com/opencloud-eu/opencloud/services/auth-api/pkg/config/defaults"
|
||||
authapp "github.com/opencloud-eu/opencloud/services/auth-app/pkg/config/defaults"
|
||||
authbasic "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/config/defaults"
|
||||
authbearer "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/config/defaults"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/config/defaults"
|
||||
graph "github.com/opencloud-eu/opencloud/services/graph/pkg/config/defaults"
|
||||
groups "github.com/opencloud-eu/opencloud/services/groups/pkg/config/defaults"
|
||||
groupware "github.com/opencloud-eu/opencloud/services/groupware/pkg/config/defaults"
|
||||
idm "github.com/opencloud-eu/opencloud/services/idm/pkg/config/defaults"
|
||||
idp "github.com/opencloud-eu/opencloud/services/idp/pkg/config/defaults"
|
||||
invitations "github.com/opencloud-eu/opencloud/services/invitations/pkg/config/defaults"
|
||||
@@ -63,6 +65,7 @@ func DefaultConfig() *Config {
|
||||
AppProvider: appProvider.DefaultConfig(),
|
||||
AppRegistry: appRegistry.DefaultConfig(),
|
||||
Audit: audit.DefaultConfig(),
|
||||
AuthApi: authapi.DefaultConfig(),
|
||||
AuthApp: authapp.DefaultConfig(),
|
||||
AuthBasic: authbasic.DefaultConfig(),
|
||||
AuthBearer: authbearer.DefaultConfig(),
|
||||
@@ -75,6 +78,7 @@ func DefaultConfig() *Config {
|
||||
Gateway: gateway.DefaultConfig(),
|
||||
Graph: graph.DefaultConfig(),
|
||||
Groups: groups.DefaultConfig(),
|
||||
Groupware: groupware.DefaultConfig(),
|
||||
IDM: idm.DefaultConfig(),
|
||||
IDP: idp.DefaultConfig(),
|
||||
Invitations: invitations.DefaultConfig(),
|
||||
|
||||
49
pkg/jmap/jmap_api.go
Normal file
49
pkg/jmap/jmap_api.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/url"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
)
|
||||
|
||||
type ApiClient interface {
|
||||
Command(ctx context.Context, logger *log.Logger, session *Session, request Request, acceptLanguage string) ([]byte, Language, Error)
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type WsPushListener interface {
|
||||
OnNotification(username string, stateChange StateChange)
|
||||
}
|
||||
|
||||
type WsClient interface {
|
||||
DisableNotifications() Error
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type WsClientFactory interface {
|
||||
EnableNotifications(pushState State, sessionProvider func() (*Session, error), listener WsPushListener) (WsClient, Error)
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type SessionClient interface {
|
||||
GetSession(baseurl *url.URL, username string, logger *log.Logger) (SessionResponse, Error)
|
||||
io.Closer
|
||||
}
|
||||
|
||||
type BlobClient interface {
|
||||
UploadBinary(ctx context.Context, logger *log.Logger, session *Session, uploadUrl string, endpoint string, contentType string, acceptLanguage string, content io.Reader) (UploadedBlob, Language, Error)
|
||||
DownloadBinary(ctx context.Context, logger *log.Logger, session *Session, downloadUrl string, endpoint string, acceptLanguage string) (*BlobDownload, Language, Error)
|
||||
io.Closer
|
||||
}
|
||||
|
||||
const (
|
||||
logOperation = "operation"
|
||||
logFetchBodies = "fetch-bodies"
|
||||
logOffset = "offset"
|
||||
logLimit = "limit"
|
||||
logDownloadUrl = "download-url"
|
||||
logBlobId = "blob-id"
|
||||
logSinceState = "since-state"
|
||||
)
|
||||
137
pkg/jmap/jmap_api_blob.go
Normal file
137
pkg/jmap/jmap_api_blob.go
Normal file
@@ -0,0 +1,137 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
)
|
||||
|
||||
func (j *Client) GetBlobMetadata(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, id string) (*Blob, SessionState, State, Language, Error) {
|
||||
cmd, jerr := j.request(session, logger,
|
||||
invocation(CommandBlobGet, BlobGetCommand{
|
||||
AccountId: accountId,
|
||||
Ids: []string{id},
|
||||
// add BlobPropertyData to retrieve the data
|
||||
Properties: []string{BlobPropertyDigestSha256, BlobPropertyDigestSha512, BlobPropertySize},
|
||||
}, "0"),
|
||||
)
|
||||
if jerr != nil {
|
||||
return nil, "", "", "", jerr
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (*Blob, State, Error) {
|
||||
var response BlobGetResponse
|
||||
err := retrieveResponseMatchParameters(logger, body, CommandBlobGet, "0", &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
if len(response.List) != 1 {
|
||||
logger.Error().Msgf("%T.List has %v entries instead of 1", response, len(response.List))
|
||||
return nil, "", simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
get := response.List[0]
|
||||
return &get, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
type UploadedBlobWithHash struct {
|
||||
BlobId string `json:"blobId"`
|
||||
Size int `json:"size,omitzero"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Sha512 string `json:"sha:512,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) UploadBlobStream(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, contentType string, body io.Reader) (UploadedBlob, Language, Error) {
|
||||
logger = log.From(logger.With().Str(logEndpoint, session.UploadEndpoint))
|
||||
// TODO(pbleser-oc) use a library for proper URL template parsing
|
||||
uploadUrl := strings.ReplaceAll(session.UploadUrlTemplate, "{accountId}", accountId)
|
||||
return j.blob.UploadBinary(ctx, logger, session, uploadUrl, session.UploadEndpoint, contentType, acceptLanguage, body)
|
||||
}
|
||||
|
||||
func (j *Client) DownloadBlobStream(accountId string, blobId string, name string, typ string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (*BlobDownload, Language, Error) {
|
||||
logger = log.From(logger.With().Str(logEndpoint, session.DownloadEndpoint))
|
||||
// TODO(pbleser-oc) use a library for proper URL template parsing
|
||||
downloadUrl := session.DownloadUrlTemplate
|
||||
downloadUrl = strings.ReplaceAll(downloadUrl, "{accountId}", accountId)
|
||||
downloadUrl = strings.ReplaceAll(downloadUrl, "{blobId}", blobId)
|
||||
downloadUrl = strings.ReplaceAll(downloadUrl, "{name}", name)
|
||||
downloadUrl = strings.ReplaceAll(downloadUrl, "{type}", typ)
|
||||
logger = log.From(logger.With().Str(logDownloadUrl, downloadUrl).Str(logBlobId, blobId))
|
||||
return j.blob.DownloadBinary(ctx, logger, session, downloadUrl, session.DownloadEndpoint, acceptLanguage)
|
||||
}
|
||||
|
||||
func (j *Client) UploadBlob(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, data []byte, contentType string) (UploadedBlobWithHash, SessionState, State, Language, Error) {
|
||||
encoded := base64.StdEncoding.EncodeToString(data)
|
||||
|
||||
upload := BlobUploadCommand{
|
||||
AccountId: accountId,
|
||||
Create: map[string]UploadObject{
|
||||
"0": {
|
||||
Data: []DataSourceObject{{
|
||||
DataAsBase64: encoded,
|
||||
}},
|
||||
Type: contentType,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
getHash := BlobGetRefCommand{
|
||||
AccountId: accountId,
|
||||
IdRef: &ResultReference{
|
||||
ResultOf: "0",
|
||||
Name: CommandBlobUpload,
|
||||
Path: "/ids",
|
||||
},
|
||||
Properties: []string{BlobPropertyDigestSha512},
|
||||
}
|
||||
|
||||
cmd, jerr := j.request(session, logger,
|
||||
invocation(CommandBlobUpload, upload, "0"),
|
||||
invocation(CommandBlobGet, getHash, "1"),
|
||||
)
|
||||
if jerr != nil {
|
||||
return UploadedBlobWithHash{}, "", "", "", jerr
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (UploadedBlobWithHash, State, Error) {
|
||||
var uploadResponse BlobUploadResponse
|
||||
err := retrieveResponseMatchParameters(logger, body, CommandBlobUpload, "0", &uploadResponse)
|
||||
if err != nil {
|
||||
return UploadedBlobWithHash{}, "", err
|
||||
}
|
||||
|
||||
var getResponse BlobGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandBlobGet, "1", &getResponse)
|
||||
if err != nil {
|
||||
return UploadedBlobWithHash{}, "", err
|
||||
}
|
||||
|
||||
if len(uploadResponse.Created) != 1 {
|
||||
logger.Error().Msgf("%T.Created has %v entries instead of 1", uploadResponse, len(uploadResponse.Created))
|
||||
return UploadedBlobWithHash{}, "", simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
upload, ok := uploadResponse.Created["0"]
|
||||
if !ok {
|
||||
logger.Error().Msgf("%T.Created has no item '0'", uploadResponse)
|
||||
return UploadedBlobWithHash{}, "", simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
if len(getResponse.List) != 1 {
|
||||
logger.Error().Msgf("%T.List has %v entries instead of 1", getResponse, len(getResponse.List))
|
||||
return UploadedBlobWithHash{}, "", simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
get := getResponse.List[0]
|
||||
|
||||
return UploadedBlobWithHash{
|
||||
BlobId: upload.Id,
|
||||
Size: upload.Size,
|
||||
Type: upload.Type,
|
||||
Sha512: get.DigestSha512,
|
||||
}, getResponse.State, nil
|
||||
})
|
||||
|
||||
}
|
||||
75
pkg/jmap/jmap_api_bootstrap.go
Normal file
75
pkg/jmap/jmap_api_bootstrap.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
type AccountBootstrapResult struct {
|
||||
Identities []Identity `json:"identities,omitempty"`
|
||||
Quotas []Quota `json:"quotas,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) GetBootstrap(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]AccountBootstrapResult, SessionState, State, Language, Error) {
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
logger = j.logger("GetBootstrap", session, logger)
|
||||
|
||||
calls := make([]Invocation, len(uniqueAccountIds)*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
calls[i*2+0] = invocation(CommandIdentityGet, IdentityGetCommand{AccountId: accountId}, mcid(accountId, "I"))
|
||||
calls[i*2+1] = invocation(CommandQuotaGet, QuotaGetCommand{AccountId: accountId}, mcid(accountId, "Q"))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, calls...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]AccountBootstrapResult, State, Error) {
|
||||
identityPerAccount := map[string][]Identity{}
|
||||
quotaPerAccount := map[string][]Quota{}
|
||||
identityStatesPerAccount := map[string]State{}
|
||||
quotaStatesPerAccount := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var identityResponse IdentityGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentityGet, mcid(accountId, "I"), &identityResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
} else {
|
||||
identityPerAccount[accountId] = identityResponse.List
|
||||
identityStatesPerAccount[accountId] = identityResponse.State
|
||||
}
|
||||
|
||||
var quotaResponse QuotaGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandQuotaGet, mcid(accountId, "Q"), "aResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
} else {
|
||||
quotaPerAccount[accountId] = quotaResponse.List
|
||||
quotaStatesPerAccount[accountId] = quotaResponse.State
|
||||
}
|
||||
}
|
||||
|
||||
result := map[string]AccountBootstrapResult{}
|
||||
for accountId, value := range identityPerAccount {
|
||||
r, ok := result[accountId]
|
||||
if !ok {
|
||||
r = AccountBootstrapResult{}
|
||||
}
|
||||
r.Identities = value
|
||||
result[accountId] = r
|
||||
}
|
||||
for accountId, value := range quotaPerAccount {
|
||||
r, ok := result[accountId]
|
||||
if !ok {
|
||||
r = AccountBootstrapResult{}
|
||||
}
|
||||
r.Quotas = value
|
||||
result[accountId] = r
|
||||
}
|
||||
|
||||
return result, squashStateMaps(identityStatesPerAccount, quotaStatesPerAccount), nil
|
||||
})
|
||||
}
|
||||
250
pkg/jmap/jmap_api_calendar.go
Normal file
250
pkg/jmap/jmap_api_calendar.go
Normal file
@@ -0,0 +1,250 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
func (j *Client) ParseICalendarBlob(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, blobIds []string) (CalendarEventParseResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("ParseICalendarBlob", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandCalendarEventParse, CalendarEventParseCommand{AccountId: accountId, BlobIds: blobIds}, "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return CalendarEventParseResponse{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (CalendarEventParseResponse, State, Error) {
|
||||
var response CalendarEventParseResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandCalendarEventParse, "0", &response)
|
||||
if err != nil {
|
||||
return CalendarEventParseResponse{}, "", err
|
||||
}
|
||||
return response, "", nil
|
||||
})
|
||||
}
|
||||
|
||||
type CalendarsResponse struct {
|
||||
Calendars []Calendar `json:"calendars"`
|
||||
NotFound []string `json:"notFound,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) GetCalendars(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) (CalendarsResponse, SessionState, State, Language, Error) {
|
||||
return getTemplate(j, "GetCalendars", CommandCalendarGet,
|
||||
func(accountId string, ids []string) CalendarGetCommand {
|
||||
return CalendarGetCommand{AccountId: accountId, Ids: ids}
|
||||
},
|
||||
func(resp CalendarGetResponse) CalendarsResponse {
|
||||
return CalendarsResponse{Calendars: resp.List, NotFound: resp.NotFound}
|
||||
},
|
||||
func(resp CalendarGetResponse) State { return resp.State },
|
||||
accountId, session, ctx, logger, acceptLanguage, ids,
|
||||
)
|
||||
}
|
||||
|
||||
func (j *Client) QueryCalendarEvents(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string,
|
||||
filter CalendarEventFilterElement, sortBy []CalendarEventComparator,
|
||||
position uint, limit uint) (map[string][]CalendarEvent, SessionState, State, Language, Error) {
|
||||
logger = j.logger("QueryCalendarEvents", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
if sortBy == nil {
|
||||
sortBy = []CalendarEventComparator{{Property: CalendarEventPropertyStart, IsAscending: false}}
|
||||
}
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds)*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
query := CalendarEventQueryCommand{
|
||||
AccountId: accountId,
|
||||
Filter: filter,
|
||||
Sort: sortBy,
|
||||
}
|
||||
if limit > 0 {
|
||||
query.Limit = limit
|
||||
}
|
||||
if position > 0 {
|
||||
query.Position = position
|
||||
}
|
||||
invocations[i*2+0] = invocation(CommandCalendarEventQuery, query, mcid(accountId, "0"))
|
||||
invocations[i*2+1] = invocation(CommandCalendarEventGet, CalendarEventGetRefCommand{
|
||||
AccountId: accountId,
|
||||
IdsRef: &ResultReference{
|
||||
Name: CommandCalendarEventQuery,
|
||||
Path: "/ids/*",
|
||||
ResultOf: mcid(accountId, "0"),
|
||||
},
|
||||
// Properties: CalendarEventProperties, // to also retrieve UTCStart and UTCEnd
|
||||
}, mcid(accountId, "1"))
|
||||
}
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string][]CalendarEvent, State, Error) {
|
||||
resp := map[string][]CalendarEvent{}
|
||||
stateByAccountId := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response CalendarEventGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandCalendarEventGet, mcid(accountId, "1"), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if len(response.NotFound) > 0 {
|
||||
// TODO what to do when there are not-found emails here? potentially nothing, they could have been deleted between query and get?
|
||||
}
|
||||
resp[accountId] = response.List
|
||||
stateByAccountId[accountId] = response.State
|
||||
}
|
||||
return resp, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) CreateCalendarEvent(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, create CalendarEvent) (*CalendarEvent, SessionState, State, Language, Error) {
|
||||
return createTemplate(j, "CreateCalendarEvent", CalendarEventType, CommandCalendarEventSet, CommandCalendarEventGet,
|
||||
func(accountId string, create map[string]CalendarEvent) CalendarEventSetCommand {
|
||||
return CalendarEventSetCommand{AccountId: accountId, Create: create}
|
||||
},
|
||||
func(accountId string, ref string) CalendarEventGetCommand {
|
||||
return CalendarEventGetCommand{AccountId: accountId, Ids: []string{ref}}
|
||||
},
|
||||
func(resp CalendarEventSetResponse) map[string]*CalendarEvent {
|
||||
return resp.Created
|
||||
},
|
||||
func(resp CalendarEventSetResponse) map[string]SetError {
|
||||
return resp.NotCreated
|
||||
},
|
||||
func(resp CalendarEventGetResponse) []CalendarEvent {
|
||||
return resp.List
|
||||
},
|
||||
func(resp CalendarEventSetResponse) State {
|
||||
return resp.NewState
|
||||
},
|
||||
accountId, session, ctx, logger, acceptLanguage, create)
|
||||
}
|
||||
|
||||
func (j *Client) DeleteCalendarEvent(accountId string, destroy []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]SetError, SessionState, State, Language, Error) {
|
||||
return deleteTemplate(j, "DeleteCalendarEvent", CommandCalendarEventSet,
|
||||
func(accountId string, destroy []string) CalendarEventSetCommand {
|
||||
return CalendarEventSetCommand{AccountId: accountId, Destroy: destroy}
|
||||
},
|
||||
func(resp CalendarEventSetResponse) map[string]SetError { return resp.NotDestroyed },
|
||||
func(resp CalendarEventSetResponse) State { return resp.NewState },
|
||||
accountId, destroy, session, ctx, logger, acceptLanguage)
|
||||
}
|
||||
|
||||
func getTemplate[GETREQ any, GETRESP any, RESP any](
|
||||
client *Client, name string, getCommand Command,
|
||||
getCommandFactory func(string, []string) GETREQ,
|
||||
mapper func(GETRESP) RESP,
|
||||
stateMapper func(GETRESP) State,
|
||||
accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) (RESP, SessionState, State, Language, Error) {
|
||||
logger = client.logger(name, session, logger)
|
||||
|
||||
var zero RESP
|
||||
|
||||
cmd, err := client.request(session, logger,
|
||||
invocation(getCommand, getCommandFactory(accountId, ids), "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return zero, "", "", "", err
|
||||
}
|
||||
|
||||
return command(client.api, logger, ctx, session, client.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (RESP, State, Error) {
|
||||
var response GETRESP
|
||||
err = retrieveResponseMatchParameters(logger, body, getCommand, "0", &response)
|
||||
if err != nil {
|
||||
return zero, "", err
|
||||
}
|
||||
|
||||
return mapper(response), stateMapper(response), nil
|
||||
})
|
||||
}
|
||||
|
||||
func createTemplate[T any, SETREQ any, GETREQ any, SETRESP any, GETRESP any](
|
||||
client *Client, name string, t ObjectType, setCommand Command, getCommand Command,
|
||||
setCommandFactory func(string, map[string]T) SETREQ,
|
||||
getCommandFactory func(string, string) GETREQ,
|
||||
createdMapper func(SETRESP) map[string]*T,
|
||||
notCreatedMapper func(SETRESP) map[string]SetError,
|
||||
listMapper func(GETRESP) []T,
|
||||
stateMapper func(SETRESP) State,
|
||||
accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, create T) (*T, SessionState, State, Language, Error) {
|
||||
logger = client.logger(name, session, logger)
|
||||
|
||||
createMap := map[string]T{"c": create}
|
||||
cmd, err := client.request(session, logger,
|
||||
invocation(setCommand, setCommandFactory(accountId, createMap), "0"),
|
||||
invocation(getCommand, getCommandFactory(accountId, "#c"), "1"),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(client.api, logger, ctx, session, client.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (*T, State, Error) {
|
||||
var setResponse SETRESP
|
||||
err = retrieveResponseMatchParameters(logger, body, setCommand, "0", &setResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
notCreatedMap := notCreatedMapper(setResponse)
|
||||
setErr, notok := notCreatedMap["c"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", setResponse, setErr)
|
||||
return nil, "", setErrorError(setErr, t)
|
||||
}
|
||||
|
||||
createdMap := createdMapper(setResponse)
|
||||
if created, ok := createdMap["c"]; !ok || created == nil {
|
||||
berr := fmt.Errorf("failed to find %s in %s response", string(t), string(setCommand))
|
||||
logger.Error().Err(berr)
|
||||
return nil, "", simpleError(berr, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
var getResponse GETRESP
|
||||
err = retrieveResponseMatchParameters(logger, body, getCommand, "1", &getResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
list := listMapper(getResponse)
|
||||
|
||||
if len(list) < 1 {
|
||||
berr := fmt.Errorf("failed to find %s in %s response", string(t), string(getCommand))
|
||||
logger.Error().Err(berr)
|
||||
return nil, "", simpleError(berr, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
return &list[0], stateMapper(setResponse), nil
|
||||
})
|
||||
}
|
||||
|
||||
func deleteTemplate[REQ any, RESP any](client *Client, name string, c Command,
|
||||
commandFactory func(string, []string) REQ,
|
||||
notDestroyedMapper func(RESP) map[string]SetError,
|
||||
stateMapper func(RESP) State,
|
||||
accountId string, destroy []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]SetError, SessionState, State, Language, Error) {
|
||||
logger = client.logger(name, session, logger)
|
||||
|
||||
cmd, err := client.request(session, logger,
|
||||
invocation(c, commandFactory(accountId, destroy), "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(client.api, logger, ctx, session, client.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]SetError, State, Error) {
|
||||
var setResponse RESP
|
||||
err = retrieveResponseMatchParameters(logger, body, c, "0", &setResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return notDestroyedMapper(setResponse), stateMapper(setResponse), nil
|
||||
})
|
||||
}
|
||||
199
pkg/jmap/jmap_api_contact.go
Normal file
199
pkg/jmap/jmap_api_contact.go
Normal file
@@ -0,0 +1,199 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/jscontact"
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
type AddressBooksResponse struct {
|
||||
AddressBooks []AddressBook `json:"addressbooks"`
|
||||
NotFound []string `json:"notFound,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) GetAddressbooks(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) (AddressBooksResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetAddressbooks", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandAddressBookGet, AddressBookGetCommand{AccountId: accountId, Ids: ids}, "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return AddressBooksResponse{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (AddressBooksResponse, State, Error) {
|
||||
var response AddressBookGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandAddressBookGet, "0", &response)
|
||||
if err != nil {
|
||||
return AddressBooksResponse{}, response.State, err
|
||||
}
|
||||
return AddressBooksResponse{
|
||||
AddressBooks: response.List,
|
||||
NotFound: response.NotFound,
|
||||
}, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) GetContactCardsById(accountId string, session *Session, ctx context.Context, logger *log.Logger,
|
||||
acceptLanguage string, contactIds []string) (map[string]jscontact.ContactCard, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetContactCardsById", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger, invocation(CommandContactCardGet, ContactCardGetCommand{
|
||||
Ids: contactIds,
|
||||
AccountId: accountId,
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]jscontact.ContactCard, State, Error) {
|
||||
var response ContactCardGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandContactCardGet, "0", &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
m := map[string]jscontact.ContactCard{}
|
||||
for _, contact := range response.List {
|
||||
m[contact.Id] = contact
|
||||
}
|
||||
return m, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) QueryContactCards(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string,
|
||||
filter ContactCardFilterElement, sortBy []ContactCardComparator,
|
||||
position uint, limit uint) (map[string][]jscontact.ContactCard, SessionState, State, Language, Error) {
|
||||
logger = j.logger("QueryContactCards", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
if sortBy == nil {
|
||||
sortBy = []ContactCardComparator{{Property: jscontact.ContactCardPropertyUpdated, IsAscending: false}}
|
||||
}
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds)*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
query := ContactCardQueryCommand{
|
||||
AccountId: accountId,
|
||||
Filter: filter,
|
||||
Sort: sortBy,
|
||||
}
|
||||
if limit > 0 {
|
||||
query.Limit = limit
|
||||
}
|
||||
if position > 0 {
|
||||
query.Position = position
|
||||
}
|
||||
invocations[i*2+0] = invocation(CommandContactCardQuery, query, mcid(accountId, "0"))
|
||||
invocations[i*2+1] = invocation(CommandContactCardGet, ContactCardGetRefCommand{
|
||||
AccountId: accountId,
|
||||
IdsRef: &ResultReference{
|
||||
Name: CommandContactCardQuery,
|
||||
Path: "/ids/*",
|
||||
ResultOf: mcid(accountId, "0"),
|
||||
},
|
||||
}, mcid(accountId, "1"))
|
||||
}
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string][]jscontact.ContactCard, State, Error) {
|
||||
resp := map[string][]jscontact.ContactCard{}
|
||||
stateByAccountId := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response ContactCardGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandContactCardGet, mcid(accountId, "1"), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if len(response.NotFound) > 0 {
|
||||
// TODO what to do when there are not-found emails here? potentially nothing, they could have been deleted between query and get?
|
||||
}
|
||||
resp[accountId] = response.List
|
||||
stateByAccountId[accountId] = response.State
|
||||
}
|
||||
return resp, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) CreateContactCard(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, create jscontact.ContactCard) (*jscontact.ContactCard, SessionState, State, Language, Error) {
|
||||
logger = j.logger("CreateContactCard", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandContactCardSet, ContactCardSetCommand{
|
||||
AccountId: accountId,
|
||||
Create: map[string]jscontact.ContactCard{
|
||||
"c": create,
|
||||
},
|
||||
}, "0"),
|
||||
invocation(CommandContactCardGet, ContactCardGetCommand{
|
||||
AccountId: accountId,
|
||||
Ids: []string{"#c"},
|
||||
}, "1"),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (*jscontact.ContactCard, State, Error) {
|
||||
var setResponse ContactCardSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandContactCardSet, "0", &setResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
setErr, notok := setResponse.NotCreated["c"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", setResponse, setErr)
|
||||
return nil, "", setErrorError(setErr, EmailType)
|
||||
}
|
||||
|
||||
if created, ok := setResponse.Created["c"]; !ok || created == nil {
|
||||
berr := fmt.Errorf("failed to find %s in %s response", string(ContactCardType), string(CommandContactCardSet))
|
||||
logger.Error().Err(berr)
|
||||
return nil, "", simpleError(berr, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
var getResponse ContactCardGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandContactCardGet, "1", &getResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
if len(getResponse.List) < 1 {
|
||||
berr := fmt.Errorf("failed to find %s in %s response", string(ContactCardType), string(CommandContactCardSet))
|
||||
logger.Error().Err(berr)
|
||||
return nil, "", simpleError(berr, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
return &getResponse.List[0], setResponse.NewState, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) DeleteContactCard(accountId string, destroy []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]SetError, SessionState, State, Language, Error) {
|
||||
logger = j.logger("DeleteContactCard", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandContactCardSet, ContactCardSetCommand{
|
||||
AccountId: accountId,
|
||||
Destroy: destroy,
|
||||
}, "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]SetError, State, Error) {
|
||||
var setResponse ContactCardSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandContactCardSet, "0", &setResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return setResponse.NotDestroyed, setResponse.NewState, nil
|
||||
})
|
||||
}
|
||||
1105
pkg/jmap/jmap_api_email.go
Normal file
1105
pkg/jmap/jmap_api_email.go
Normal file
File diff suppressed because it is too large
Load Diff
208
pkg/jmap/jmap_api_identity.go
Normal file
208
pkg/jmap/jmap_api_identity.go
Normal file
@@ -0,0 +1,208 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
func (j *Client) GetAllIdentities(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) ([]Identity, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetAllIdentities", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandIdentityGet, IdentityGetCommand{AccountId: accountId}, "0"))
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) ([]Identity, State, Error) {
|
||||
var response IdentityGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentityGet, "0", &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return response.List, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) GetIdentities(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, identityIds []string) ([]Identity, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetIdentities", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandIdentityGet, IdentityGetCommand{AccountId: accountId, Ids: identityIds}, "0"))
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) ([]Identity, State, Error) {
|
||||
var response IdentityGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentityGet, "0", &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return response.List, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
type IdentitiesGetResponse struct {
|
||||
Identities map[string][]Identity `json:"identities,omitempty"`
|
||||
NotFound []string `json:"notFound,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) GetIdentitiesForAllAccounts(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (IdentitiesGetResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetIdentitiesForAllAccounts", session, logger)
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
calls := make([]Invocation, len(uniqueAccountIds))
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
calls[i] = invocation(CommandIdentityGet, IdentityGetCommand{AccountId: accountId}, strconv.Itoa(i))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, calls...)
|
||||
if err != nil {
|
||||
return IdentitiesGetResponse{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (IdentitiesGetResponse, State, Error) {
|
||||
identities := make(map[string][]Identity, len(uniqueAccountIds))
|
||||
stateByAccountId := make(map[string]State, len(uniqueAccountIds))
|
||||
notFound := []string{}
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
var response IdentityGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentityGet, strconv.Itoa(i), &response)
|
||||
if err != nil {
|
||||
return IdentitiesGetResponse{}, "", err
|
||||
} else {
|
||||
identities[accountId] = response.List
|
||||
}
|
||||
stateByAccountId[accountId] = response.State
|
||||
notFound = append(notFound, response.NotFound...)
|
||||
}
|
||||
|
||||
return IdentitiesGetResponse{
|
||||
Identities: identities,
|
||||
NotFound: structs.Uniq(notFound),
|
||||
}, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
type IdentitiesAndMailboxesGetResponse struct {
|
||||
Identities map[string][]Identity `json:"identities,omitempty"`
|
||||
NotFound []string `json:"notFound,omitempty"`
|
||||
Mailboxes []Mailbox `json:"mailboxes"`
|
||||
}
|
||||
|
||||
func (j *Client) GetIdentitiesAndMailboxes(mailboxAccountId string, accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (IdentitiesAndMailboxesGetResponse, SessionState, State, Language, Error) {
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
logger = j.logger("GetIdentitiesAndMailboxes", session, logger)
|
||||
|
||||
calls := make([]Invocation, len(uniqueAccountIds)+1)
|
||||
calls[0] = invocation(CommandMailboxGet, MailboxGetCommand{AccountId: mailboxAccountId}, "0")
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
calls[i+1] = invocation(CommandIdentityGet, IdentityGetCommand{AccountId: accountId}, strconv.Itoa(i+1))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, calls...)
|
||||
if err != nil {
|
||||
return IdentitiesAndMailboxesGetResponse{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (IdentitiesAndMailboxesGetResponse, State, Error) {
|
||||
identities := make(map[string][]Identity, len(uniqueAccountIds))
|
||||
stateByAccountId := make(map[string]State, len(uniqueAccountIds))
|
||||
notFound := []string{}
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
var response IdentityGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentityGet, strconv.Itoa(i+1), &response)
|
||||
if err != nil {
|
||||
return IdentitiesAndMailboxesGetResponse{}, "", err
|
||||
} else {
|
||||
identities[accountId] = response.List
|
||||
}
|
||||
stateByAccountId[accountId] = response.State
|
||||
notFound = append(notFound, response.NotFound...)
|
||||
}
|
||||
|
||||
var mailboxResponse MailboxGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, "0", &mailboxResponse)
|
||||
if err != nil {
|
||||
return IdentitiesAndMailboxesGetResponse{}, "", err
|
||||
}
|
||||
|
||||
return IdentitiesAndMailboxesGetResponse{
|
||||
Identities: identities,
|
||||
NotFound: structs.Uniq(notFound),
|
||||
Mailboxes: mailboxResponse.List,
|
||||
}, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) CreateIdentity(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, identity Identity) (Identity, SessionState, State, Language, Error) {
|
||||
logger = j.logger("CreateIdentity", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandIdentitySet, IdentitySetCommand{
|
||||
AccountId: accountId,
|
||||
Create: map[string]Identity{
|
||||
"c": identity,
|
||||
},
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return Identity{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (Identity, State, Error) {
|
||||
var response IdentitySetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentitySet, "0", &response)
|
||||
if err != nil {
|
||||
return Identity{}, response.NewState, err
|
||||
}
|
||||
setErr, notok := response.NotCreated["c"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", response, setErr)
|
||||
return Identity{}, "", setErrorError(setErr, IdentityType)
|
||||
}
|
||||
return response.Created["c"], response.NewState, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) UpdateIdentity(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, identity Identity) (Identity, SessionState, State, Language, Error) {
|
||||
logger = j.logger("UpdateIdentity", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandIdentitySet, IdentitySetCommand{
|
||||
AccountId: accountId,
|
||||
Update: map[string]PatchObject{
|
||||
"c": identity.AsPatch(),
|
||||
},
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return Identity{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (Identity, State, Error) {
|
||||
var response IdentitySetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentitySet, "0", &response)
|
||||
if err != nil {
|
||||
return Identity{}, response.NewState, err
|
||||
}
|
||||
setErr, notok := response.NotCreated["c"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", response, setErr)
|
||||
return Identity{}, "", setErrorError(setErr, IdentityType)
|
||||
}
|
||||
return response.Created["c"], response.NewState, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) DeleteIdentity(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) ([]string, SessionState, State, Language, Error) {
|
||||
logger = j.logger("DeleteIdentity", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandIdentitySet, IdentitySetCommand{
|
||||
AccountId: accountId,
|
||||
Destroy: ids,
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) ([]string, State, Error) {
|
||||
var response IdentitySetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandIdentitySet, "0", &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
for _, setErr := range response.NotDestroyed {
|
||||
// TODO only returning the first error here, we should probably aggregate them instead
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", response, setErr)
|
||||
return nil, "", setErrorError(setErr, IdentityType)
|
||||
}
|
||||
return response.Destroyed, response.NewState, nil
|
||||
})
|
||||
}
|
||||
518
pkg/jmap/jmap_api_mailbox.go
Normal file
518
pkg/jmap/jmap_api_mailbox.go
Normal file
@@ -0,0 +1,518 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
type MailboxesResponse struct {
|
||||
Mailboxes []Mailbox `json:"mailboxes"`
|
||||
NotFound []any `json:"notFound"`
|
||||
}
|
||||
|
||||
// https://jmap.io/spec-mail.html#mailboxget
|
||||
func (j *Client) GetMailbox(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) (MailboxesResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetMailbox", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandMailboxGet, MailboxGetCommand{AccountId: accountId, Ids: ids}, "0"),
|
||||
)
|
||||
if err != nil {
|
||||
return MailboxesResponse{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (MailboxesResponse, State, Error) {
|
||||
var response MailboxGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, "0", &response)
|
||||
if err != nil {
|
||||
return MailboxesResponse{}, "", err
|
||||
}
|
||||
return MailboxesResponse{
|
||||
Mailboxes: response.List,
|
||||
NotFound: response.NotFound,
|
||||
}, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) GetAllMailboxes(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string][]Mailbox, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetAllMailboxes", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
n := len(uniqueAccountIds)
|
||||
if n < 1 {
|
||||
return nil, "", "", "", nil
|
||||
}
|
||||
|
||||
invocations := make([]Invocation, n)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i] = invocation(CommandMailboxGet, MailboxGetCommand{AccountId: accountId}, mcid(accountId, "0"))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string][]Mailbox, State, Error) {
|
||||
resp := map[string][]Mailbox{}
|
||||
stateByAccountid := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response MailboxGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, mcid(accountId, "0"), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
resp[accountId] = response.List
|
||||
stateByAccountid[accountId] = response.State
|
||||
}
|
||||
return resp, squashState(stateByAccountid), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) SearchMailboxes(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, filter MailboxFilterElement) (map[string][]Mailbox, SessionState, State, Language, Error) {
|
||||
logger = j.logger("SearchMailboxes", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds)*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i*2+0] = invocation(CommandMailboxQuery, MailboxQueryCommand{AccountId: accountId, Filter: filter}, mcid(accountId, "0"))
|
||||
invocations[i*2+1] = invocation(CommandMailboxGet, MailboxGetRefCommand{
|
||||
AccountId: accountId,
|
||||
IdsRef: &ResultReference{
|
||||
Name: CommandMailboxQuery,
|
||||
Path: "/ids/*",
|
||||
ResultOf: mcid(accountId, "0"),
|
||||
},
|
||||
}, mcid(accountId, "1"))
|
||||
}
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string][]Mailbox, State, Error) {
|
||||
resp := map[string][]Mailbox{}
|
||||
stateByAccountid := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response MailboxGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, mcid(accountId, "1"), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
resp[accountId] = response.List
|
||||
stateByAccountid[accountId] = response.State
|
||||
}
|
||||
return resp, squashState(stateByAccountid), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) SearchMailboxIdsPerRole(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, roles []string) (map[string]map[string]string, SessionState, State, Language, Error) {
|
||||
logger = j.logger("SearchMailboxIdsPerRole", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds)*len(roles))
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
for j, role := range roles {
|
||||
invocations[i*len(roles)+j] = invocation(CommandMailboxQuery, MailboxQueryCommand{AccountId: accountId, Filter: MailboxFilterCondition{Role: role}}, mcid(accountId, role))
|
||||
}
|
||||
}
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]map[string]string, State, Error) {
|
||||
resp := map[string]map[string]string{}
|
||||
stateByAccountid := map[string]State{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
mailboxIdsByRole := map[string]string{}
|
||||
for _, role := range roles {
|
||||
var response MailboxQueryResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxQuery, mcid(accountId, role), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if len(response.Ids) == 1 {
|
||||
mailboxIdsByRole[role] = response.Ids[0]
|
||||
}
|
||||
if _, ok := stateByAccountid[accountId]; !ok {
|
||||
stateByAccountid[accountId] = response.QueryState
|
||||
}
|
||||
}
|
||||
resp[accountId] = mailboxIdsByRole
|
||||
}
|
||||
return resp, squashState(stateByAccountid), nil
|
||||
})
|
||||
}
|
||||
|
||||
type MailboxChanges struct {
|
||||
Destroyed []string `json:"destroyed,omitzero"`
|
||||
HasMoreChanges bool `json:"hasMoreChanges,omitzero"`
|
||||
NewState State `json:"newState"`
|
||||
Created []Email `json:"created,omitempty"`
|
||||
Updated []Email `json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
// Retrieve Email changes in a given Mailbox since a given state.
|
||||
func (j *Client) GetMailboxChanges(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, mailboxId string, sinceState string, fetchBodies bool, maxBodyValueBytes uint, maxChanges uint) (MailboxChanges, SessionState, State, Language, Error) {
|
||||
logger = j.loggerParams("GetMailboxChanges", session, logger, func(z zerolog.Context) zerolog.Context {
|
||||
return z.Bool(logFetchBodies, fetchBodies).Str(logSinceState, sinceState)
|
||||
})
|
||||
|
||||
changes := MailboxChangesCommand{
|
||||
AccountId: accountId,
|
||||
SinceState: sinceState,
|
||||
}
|
||||
if maxChanges > 0 {
|
||||
changes.MaxChanges = maxChanges
|
||||
}
|
||||
|
||||
getCreated := EmailGetRefCommand{
|
||||
AccountId: accountId,
|
||||
FetchAllBodyValues: fetchBodies,
|
||||
IdsRef: &ResultReference{Name: CommandMailboxChanges, Path: "/created", ResultOf: "0"},
|
||||
}
|
||||
if maxBodyValueBytes > 0 {
|
||||
getCreated.MaxBodyValueBytes = maxBodyValueBytes
|
||||
}
|
||||
getUpdated := EmailGetRefCommand{
|
||||
AccountId: accountId,
|
||||
FetchAllBodyValues: fetchBodies,
|
||||
IdsRef: &ResultReference{Name: CommandMailboxChanges, Path: "/updated", ResultOf: "0"},
|
||||
}
|
||||
if maxBodyValueBytes > 0 {
|
||||
getUpdated.MaxBodyValueBytes = maxBodyValueBytes
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandMailboxChanges, changes, "0"),
|
||||
invocation(CommandEmailGet, getCreated, "1"),
|
||||
invocation(CommandEmailGet, getUpdated, "2"),
|
||||
)
|
||||
if err != nil {
|
||||
return MailboxChanges{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (MailboxChanges, State, Error) {
|
||||
var mailboxResponse MailboxChangesResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxChanges, "0", &mailboxResponse)
|
||||
if err != nil {
|
||||
return MailboxChanges{}, "", err
|
||||
}
|
||||
|
||||
var createdResponse EmailGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandEmailGet, "1", &createdResponse)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Send()
|
||||
return MailboxChanges{}, "", err
|
||||
}
|
||||
|
||||
var updatedResponse EmailGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandEmailGet, "2", &updatedResponse)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Send()
|
||||
return MailboxChanges{}, "", err
|
||||
}
|
||||
|
||||
return MailboxChanges{
|
||||
Destroyed: mailboxResponse.Destroyed,
|
||||
HasMoreChanges: mailboxResponse.HasMoreChanges,
|
||||
NewState: mailboxResponse.NewState,
|
||||
Created: createdResponse.List,
|
||||
Updated: createdResponse.List,
|
||||
}, createdResponse.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
// Retrieve Email changes in Mailboxes of multiple Accounts.
|
||||
func (j *Client) GetMailboxChangesForMultipleAccounts(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, sinceStateMap map[string]string, fetchBodies bool, maxBodyValueBytes uint, maxChanges uint) (map[string]MailboxChanges, SessionState, State, Language, Error) {
|
||||
logger = j.loggerParams("GetMailboxChangesForMultipleAccounts", session, logger, func(z zerolog.Context) zerolog.Context {
|
||||
sinceStateLogDict := zerolog.Dict()
|
||||
for k, v := range sinceStateMap {
|
||||
sinceStateLogDict.Str(log.SafeString(k), log.SafeString(v))
|
||||
}
|
||||
return z.Bool(logFetchBodies, fetchBodies).Dict(logSinceState, sinceStateLogDict)
|
||||
})
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
n := len(uniqueAccountIds)
|
||||
if n < 1 {
|
||||
return map[string]MailboxChanges{}, "", "", "", nil
|
||||
}
|
||||
|
||||
invocations := make([]Invocation, n*3)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
changes := MailboxChangesCommand{
|
||||
AccountId: accountId,
|
||||
}
|
||||
|
||||
sinceState, ok := sinceStateMap[accountId]
|
||||
if ok {
|
||||
changes.SinceState = sinceState
|
||||
}
|
||||
|
||||
if maxChanges > 0 {
|
||||
changes.MaxChanges = maxChanges
|
||||
}
|
||||
|
||||
getCreated := EmailGetRefCommand{
|
||||
AccountId: accountId,
|
||||
FetchAllBodyValues: fetchBodies,
|
||||
IdsRef: &ResultReference{Name: CommandMailboxChanges, Path: "/created", ResultOf: mcid(accountId, "0")},
|
||||
}
|
||||
if maxBodyValueBytes > 0 {
|
||||
getCreated.MaxBodyValueBytes = maxBodyValueBytes
|
||||
}
|
||||
getUpdated := EmailGetRefCommand{
|
||||
AccountId: accountId,
|
||||
FetchAllBodyValues: fetchBodies,
|
||||
IdsRef: &ResultReference{Name: CommandMailboxChanges, Path: "/updated", ResultOf: mcid(accountId, "0")},
|
||||
}
|
||||
if maxBodyValueBytes > 0 {
|
||||
getUpdated.MaxBodyValueBytes = maxBodyValueBytes
|
||||
}
|
||||
|
||||
invocations[i*3+0] = invocation(CommandMailboxChanges, changes, mcid(accountId, "0"))
|
||||
invocations[i*3+1] = invocation(CommandEmailGet, getCreated, mcid(accountId, "1"))
|
||||
invocations[i*3+2] = invocation(CommandEmailGet, getUpdated, mcid(accountId, "2"))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]MailboxChanges, State, Error) {
|
||||
resp := make(map[string]MailboxChanges, n)
|
||||
stateByAccountId := make(map[string]State, n)
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var mailboxResponse MailboxChangesResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxChanges, mcid(accountId, "0"), &mailboxResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
var createdResponse EmailGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandEmailGet, mcid(accountId, "1"), &createdResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
var updatedResponse EmailGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandEmailGet, mcid(accountId, "2"), &updatedResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
resp[accountId] = MailboxChanges{
|
||||
Destroyed: mailboxResponse.Destroyed,
|
||||
HasMoreChanges: mailboxResponse.HasMoreChanges,
|
||||
NewState: mailboxResponse.NewState,
|
||||
Created: createdResponse.List,
|
||||
Updated: createdResponse.List,
|
||||
}
|
||||
stateByAccountId[accountId] = createdResponse.State
|
||||
}
|
||||
|
||||
return resp, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) GetMailboxRolesForMultipleAccounts(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string][]string, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetMailboxRolesForMultipleAccounts", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
n := len(uniqueAccountIds)
|
||||
if n < 1 {
|
||||
return nil, "", "", "", nil
|
||||
}
|
||||
|
||||
t := true
|
||||
|
||||
invocations := make([]Invocation, n*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i*2+0] = invocation(CommandMailboxQuery, MailboxQueryCommand{
|
||||
AccountId: accountId,
|
||||
Filter: MailboxFilterCondition{
|
||||
HasAnyRole: &t,
|
||||
},
|
||||
}, mcid(accountId, "0"))
|
||||
invocations[i*2+1] = invocation(CommandMailboxGet, MailboxGetRefCommand{
|
||||
AccountId: accountId,
|
||||
IdsRef: &ResultReference{
|
||||
ResultOf: mcid(accountId, "0"),
|
||||
Name: CommandMailboxQuery,
|
||||
Path: "/ids",
|
||||
},
|
||||
}, mcid(accountId, "1"))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string][]string, State, Error) {
|
||||
resp := make(map[string][]string, n)
|
||||
stateByAccountId := make(map[string]State, n)
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var getResponse MailboxGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, mcid(accountId, "1"), &getResponse)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
roles := make([]string, len(getResponse.List))
|
||||
for i, mailbox := range getResponse.List {
|
||||
roles[i] = mailbox.Role
|
||||
}
|
||||
slices.Sort(roles)
|
||||
resp[accountId] = roles
|
||||
stateByAccountId[accountId] = getResponse.State
|
||||
}
|
||||
return resp, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) GetInboxNameForMultipleAccounts(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]string, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetInboxNameForMultipleAccounts", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
n := len(uniqueAccountIds)
|
||||
if n < 1 {
|
||||
return nil, "", "", "", nil
|
||||
}
|
||||
|
||||
invocations := make([]Invocation, n*2)
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i*2+0] = invocation(CommandMailboxQuery, MailboxQueryCommand{
|
||||
AccountId: accountId,
|
||||
Filter: MailboxFilterCondition{
|
||||
Role: JmapMailboxRoleInbox,
|
||||
},
|
||||
}, mcid(accountId, "0"))
|
||||
}
|
||||
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]string, State, Error) {
|
||||
resp := make(map[string]string, n)
|
||||
stateByAccountId := make(map[string]State, n)
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var r MailboxQueryResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxGet, mcid(accountId, "0"), &r)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
switch len(r.Ids) {
|
||||
case 0:
|
||||
// skip: account has no inbox?
|
||||
case 1:
|
||||
resp[accountId] = r.Ids[0]
|
||||
stateByAccountId[accountId] = r.QueryState
|
||||
default:
|
||||
logger.Warn().Msgf("multiple ids for mailbox role='%v' for accountId='%v'", JmapMailboxRoleInbox, accountId)
|
||||
resp[accountId] = r.Ids[0]
|
||||
stateByAccountId[accountId] = r.QueryState
|
||||
}
|
||||
}
|
||||
return resp, squashState(stateByAccountId), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) UpdateMailbox(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, mailboxId string, ifInState string, update MailboxChange) (Mailbox, SessionState, State, Language, Error) {
|
||||
logger = j.logger("UpdateMailbox", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandMailboxSet, MailboxSetCommand{
|
||||
AccountId: accountId,
|
||||
IfInState: ifInState,
|
||||
Update: map[string]PatchObject{
|
||||
mailboxId: update.AsPatch(),
|
||||
},
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return Mailbox{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (Mailbox, State, Error) {
|
||||
var setResp MailboxSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxSet, "0", &setResp)
|
||||
if err != nil {
|
||||
return Mailbox{}, "", err
|
||||
}
|
||||
setErr, notok := setResp.NotUpdated["u"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotUpdated returned an error %v", setResp, setErr)
|
||||
return Mailbox{}, "", setErrorError(setErr, MailboxType)
|
||||
}
|
||||
return setResp.Updated["c"], setResp.NewState, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) CreateMailbox(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ifInState string, create MailboxChange) (Mailbox, SessionState, State, Language, Error) {
|
||||
logger = j.logger("CreateMailbox", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandMailboxSet, MailboxSetCommand{
|
||||
AccountId: accountId,
|
||||
IfInState: ifInState,
|
||||
Create: map[string]MailboxChange{
|
||||
"c": create,
|
||||
},
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return Mailbox{}, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (Mailbox, State, Error) {
|
||||
var setResp MailboxSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxSet, "0", &setResp)
|
||||
if err != nil {
|
||||
return Mailbox{}, "", err
|
||||
}
|
||||
setErr, notok := setResp.NotCreated["c"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotCreated returned an error %v", setResp, setErr)
|
||||
return Mailbox{}, "", setErrorError(setErr, MailboxType)
|
||||
}
|
||||
if mailbox, ok := setResp.Created["c"]; ok {
|
||||
return mailbox, setResp.NewState, nil
|
||||
} else {
|
||||
return Mailbox{}, "", simpleError(fmt.Errorf("failed to find created %T in response", Mailbox{}), JmapErrorMissingCreatedObject)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) DeleteMailboxes(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ifInState string, mailboxIds []string) ([]string, SessionState, State, Language, Error) {
|
||||
logger = j.logger("DeleteMailbox", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandMailboxSet, MailboxSetCommand{
|
||||
AccountId: accountId,
|
||||
IfInState: ifInState,
|
||||
Destroy: mailboxIds,
|
||||
}, "0"))
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) ([]string, State, Error) {
|
||||
var setResp MailboxSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandMailboxSet, "0", &setResp)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
setErr, notok := setResp.NotUpdated["u"]
|
||||
if notok {
|
||||
logger.Error().Msgf("%T.NotUpdated returned an error %v", setResp, setErr)
|
||||
return nil, "", setErrorError(setErr, MailboxType)
|
||||
}
|
||||
return setResp.Destroyed, setResp.NewState, nil
|
||||
})
|
||||
}
|
||||
35
pkg/jmap/jmap_api_quota.go
Normal file
35
pkg/jmap/jmap_api_quota.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
func (j *Client) GetQuotas(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]QuotaGetResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetQuotas", session, logger)
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds))
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i] = invocation(CommandQuotaGet, MailboxQueryCommand{AccountId: accountId}, mcid(accountId, "0"))
|
||||
}
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]QuotaGetResponse, State, Error) {
|
||||
result := map[string]QuotaGetResponse{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response QuotaGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandQuotaGet, mcid(accountId, "0"), &response)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
result[accountId] = response
|
||||
}
|
||||
return result, squashStateFunc(result, func(q QuotaGetResponse) State { return q.State }), nil
|
||||
})
|
||||
}
|
||||
108
pkg/jmap/jmap_api_vacation.go
Normal file
108
pkg/jmap/jmap_api_vacation.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
)
|
||||
|
||||
const (
|
||||
vacationResponseId = "singleton"
|
||||
)
|
||||
|
||||
// https://jmap.io/spec-mail.html#vacationresponseget
|
||||
func (j *Client) GetVacationResponse(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (VacationResponseGetResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("GetVacationResponse", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandVacationResponseGet, VacationResponseGetCommand{AccountId: accountId}, "0"))
|
||||
if err != nil {
|
||||
return VacationResponseGetResponse{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (VacationResponseGetResponse, State, Error) {
|
||||
var response VacationResponseGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandVacationResponseGet, "0", &response)
|
||||
if err != nil {
|
||||
return VacationResponseGetResponse{}, "", err
|
||||
}
|
||||
return response, response.State, nil
|
||||
})
|
||||
}
|
||||
|
||||
// Same as VacationResponse but without the id.
|
||||
type VacationResponsePayload struct {
|
||||
// Should a vacation response be sent if a message arrives between the "fromDate" and "toDate"?
|
||||
IsEnabled bool `json:"isEnabled"`
|
||||
// If "isEnabled" is true, messages that arrive on or after this date-time (but before the "toDate" if defined) should receive the
|
||||
// user's vacation response. If null, the vacation response is effective immediately.
|
||||
FromDate time.Time `json:"fromDate,omitzero"`
|
||||
// If "isEnabled" is true, messages that arrive before this date-time but on or after the "fromDate" if defined) should receive the
|
||||
// user's vacation response. If null, the vacation response is effective indefinitely.
|
||||
ToDate time.Time `json:"toDate,omitzero"`
|
||||
// The subject that will be used by the message sent in response to messages when the vacation response is enabled.
|
||||
// If null, an appropriate subject SHOULD be set by the server.
|
||||
Subject string `json:"subject,omitempty"`
|
||||
// The plaintext body to send in response to messages when the vacation response is enabled.
|
||||
// If this is null, the server SHOULD generate a plaintext body part from the "htmlBody" when sending vacation responses
|
||||
// but MAY choose to send the response as HTML only. If both "textBody" and "htmlBody" are null, an appropriate default
|
||||
// body SHOULD be generated for responses by the server.
|
||||
TextBody string `json:"textBody,omitempty"`
|
||||
// The HTML body to send in response to messages when the vacation response is enabled.
|
||||
// If this is null, the server MAY choose to generate an HTML body part from the "textBody" when sending vacation responses
|
||||
// or MAY choose to send the response as plaintext only.
|
||||
HtmlBody string `json:"htmlBody,omitempty"`
|
||||
}
|
||||
|
||||
func (j *Client) SetVacationResponse(accountId string, vacation VacationResponsePayload, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (VacationResponse, SessionState, State, Language, Error) {
|
||||
logger = j.logger("SetVacationResponse", session, logger)
|
||||
|
||||
cmd, err := j.request(session, logger,
|
||||
invocation(CommandVacationResponseSet, VacationResponseSetCommand{
|
||||
AccountId: accountId,
|
||||
Create: map[string]VacationResponse{
|
||||
vacationResponseId: {
|
||||
IsEnabled: vacation.IsEnabled,
|
||||
FromDate: vacation.FromDate,
|
||||
ToDate: vacation.ToDate,
|
||||
Subject: vacation.Subject,
|
||||
TextBody: vacation.TextBody,
|
||||
HtmlBody: vacation.HtmlBody,
|
||||
},
|
||||
},
|
||||
}, "0"),
|
||||
// chain a second request to get the current complete VacationResponse object
|
||||
// after performing the changes, as that makes for a better API
|
||||
invocation(CommandVacationResponseGet, VacationResponseGetCommand{AccountId: accountId}, "1"),
|
||||
)
|
||||
if err != nil {
|
||||
return VacationResponse{}, "", "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (VacationResponse, State, Error) {
|
||||
var setResponse VacationResponseSetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandVacationResponseSet, "0", &setResponse)
|
||||
if err != nil {
|
||||
return VacationResponse{}, "", err
|
||||
}
|
||||
|
||||
setErr, notok := setResponse.NotCreated[vacationResponseId]
|
||||
if notok {
|
||||
// this means that the VacationResponse was not updated
|
||||
logger.Error().Msgf("%T.NotCreated contains an error: %v", setResponse, setErr)
|
||||
return VacationResponse{}, "", setErrorError(setErr, VacationResponseType)
|
||||
}
|
||||
|
||||
var getResponse VacationResponseGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandVacationResponseGet, "1", &getResponse)
|
||||
if err != nil {
|
||||
return VacationResponse{}, "", err
|
||||
}
|
||||
|
||||
if len(getResponse.List) != 1 {
|
||||
berr := fmt.Errorf("failed to find %s in %s response", string(VacationResponseType), string(CommandVacationResponseGet))
|
||||
logger.Error().Msg(berr.Error())
|
||||
return VacationResponse{}, "", simpleError(berr, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
|
||||
return getResponse.List[0], setResponse.NewState, nil
|
||||
})
|
||||
}
|
||||
9
pkg/jmap/jmap_api_ws.go
Normal file
9
pkg/jmap/jmap_api_ws.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package jmap
|
||||
|
||||
func (j *Client) EnablePushNotifications(pushState State, sessionProvider func() (*Session, error)) (WsClient, error) {
|
||||
return j.ws.EnableNotifications(pushState, sessionProvider, j)
|
||||
}
|
||||
|
||||
func (j *Client) AddWsPushListener(listener WsPushListener) {
|
||||
j.wsPushListeners.add(listener)
|
||||
}
|
||||
103
pkg/jmap/jmap_client.go
Normal file
103
pkg/jmap/jmap_client.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/url"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
session SessionClient
|
||||
api ApiClient
|
||||
blob BlobClient
|
||||
ws WsClientFactory
|
||||
sessionEventListeners *eventListeners[SessionEventListener]
|
||||
wsPushListeners *eventListeners[WsPushListener]
|
||||
io.Closer
|
||||
WsPushListener
|
||||
}
|
||||
|
||||
var _ io.Closer = &Client{}
|
||||
var _ WsPushListener = &Client{}
|
||||
|
||||
func (j *Client) Close() error {
|
||||
return errors.Join(j.api.Close(), j.session.Close(), j.blob.Close(), j.ws.Close())
|
||||
}
|
||||
|
||||
func NewClient(session SessionClient, api ApiClient, blob BlobClient, ws WsClientFactory) Client {
|
||||
return Client{
|
||||
session: session,
|
||||
api: api,
|
||||
blob: blob,
|
||||
ws: ws,
|
||||
sessionEventListeners: newEventListeners[SessionEventListener](),
|
||||
wsPushListeners: newEventListeners[WsPushListener](),
|
||||
}
|
||||
}
|
||||
|
||||
func (j *Client) AddSessionEventListener(listener SessionEventListener) {
|
||||
j.sessionEventListeners.add(listener)
|
||||
}
|
||||
|
||||
func (j *Client) onSessionOutdated(session *Session, newSessionState SessionState) {
|
||||
j.sessionEventListeners.signal(func(listener SessionEventListener) {
|
||||
listener.OnSessionOutdated(session, newSessionState)
|
||||
})
|
||||
}
|
||||
|
||||
func (j *Client) OnNotification(username string, stateChange StateChange) {
|
||||
j.wsPushListeners.signal(func(listener WsPushListener) {
|
||||
listener.OnNotification(username, stateChange)
|
||||
})
|
||||
}
|
||||
|
||||
// Retrieve JMAP well-known data from the Stalwart server and create a Session from that.
|
||||
func (j *Client) FetchSession(sessionUrl *url.URL, username string, logger *log.Logger) (Session, Error) {
|
||||
wk, err := j.session.GetSession(sessionUrl, username, logger)
|
||||
if err != nil {
|
||||
return Session{}, err
|
||||
}
|
||||
return newSession(wk)
|
||||
}
|
||||
|
||||
func (j *Client) logger(operation string, _ *Session, logger *log.Logger) *log.Logger {
|
||||
l := logger.With().Str(logOperation, operation)
|
||||
return log.From(l)
|
||||
}
|
||||
|
||||
func (j *Client) loggerParams(operation string, _ *Session, logger *log.Logger, params func(zerolog.Context) zerolog.Context) *log.Logger {
|
||||
l := logger.With().Str(logOperation, operation)
|
||||
if params != nil {
|
||||
l = params(l)
|
||||
}
|
||||
return log.From(l)
|
||||
}
|
||||
|
||||
func (j *Client) maxCallsCheck(calls int, session *Session, logger *log.Logger) Error {
|
||||
if calls > session.Capabilities.Core.MaxCallsInRequest {
|
||||
logger.Warn().
|
||||
Int("max-calls-in-request", session.Capabilities.Core.MaxCallsInRequest).
|
||||
Int("calls-in-request", calls).
|
||||
Msgf("number of calls in request payload (%d) would exceed the allowed maximum (%d)", session.Capabilities.Core.MaxCallsInRequest, calls)
|
||||
return simpleError(errTooManyMethodCalls, JmapErrorTooManyMethodCalls)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Construct a Request from the given list of Invocation objects.
|
||||
//
|
||||
// If an issue occurs, then it is logged prior to returning it.
|
||||
func (j *Client) request(session *Session, logger *log.Logger, methodCalls ...Invocation) (Request, Error) {
|
||||
err := j.maxCallsCheck(len(methodCalls), session, logger)
|
||||
if err != nil {
|
||||
return Request{}, err
|
||||
}
|
||||
return Request{
|
||||
Using: []string{JmapCore, JmapMail, JmapContacts},
|
||||
MethodCalls: methodCalls,
|
||||
CreatedIds: nil,
|
||||
}, nil
|
||||
}
|
||||
89
pkg/jmap/jmap_error.go
Normal file
89
pkg/jmap/jmap_error.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
JmapErrorAuthenticationFailed = iota
|
||||
JmapErrorInvalidHttpRequest
|
||||
JmapErrorServerResponse
|
||||
JmapErrorReadingResponseBody
|
||||
JmapErrorDecodingResponseBody
|
||||
JmapErrorEncodingRequestBody
|
||||
JmapErrorCreatingRequest
|
||||
JmapErrorSendingRequest
|
||||
JmapErrorInvalidSessionResponse
|
||||
JmapErrorInvalidJmapRequestPayload
|
||||
JmapErrorInvalidJmapResponsePayload
|
||||
JmapErrorSetError
|
||||
JmapErrorTooManyMethodCalls
|
||||
JmapErrorUnspecifiedType
|
||||
JmapErrorServerUnavailable
|
||||
JmapErrorServerFail
|
||||
JmapErrorUnknownMethod
|
||||
JmapErrorInvalidArguments
|
||||
JmapErrorInvalidResultReference
|
||||
JmapErrorForbidden
|
||||
JmapErrorAccountNotFound
|
||||
JmapErrorAccountNotSupportedByMethod
|
||||
JmapErrorAccountReadOnly
|
||||
JmapErrorFailedToEstablishWssConnection
|
||||
JmapErrorWssConnectionResponseMissingJmapSubprotocol
|
||||
JmapErrorWssFailedToSendWebSocketPushEnable
|
||||
JmapErrorWssFailedToSendWebSocketPushDisable
|
||||
JmapErrorWssFailedToClose
|
||||
JmapErrorWssFailedToRetrieveSession
|
||||
JmapErrorSocketPushUnsupported
|
||||
JmapErrorMissingCreatedObject
|
||||
)
|
||||
|
||||
var (
|
||||
errTooManyMethodCalls = errors.New("the amount of methodCalls in the request body would exceed the maximum that is configured in the session")
|
||||
)
|
||||
|
||||
type Error interface {
|
||||
Code() int
|
||||
error
|
||||
}
|
||||
|
||||
type SimpleError struct {
|
||||
code int
|
||||
err error
|
||||
}
|
||||
|
||||
var _ Error = &SimpleError{}
|
||||
|
||||
func (e SimpleError) Code() int {
|
||||
return e.code
|
||||
}
|
||||
func (e SimpleError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
func (e SimpleError) Error() string {
|
||||
if e.err != nil {
|
||||
return e.err.Error()
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func simpleError(err error, code int) Error {
|
||||
if err != nil {
|
||||
return SimpleError{code: code, err: err}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func setErrorError(err SetError, objectType ObjectType) Error {
|
||||
var e error
|
||||
if len(err.Properties) > 0 {
|
||||
e = fmt.Errorf("failed to modify %s due to %s error in properties [%s]: %s", objectType, err.Type, strings.Join(err.Properties, ", "), err.Description)
|
||||
} else {
|
||||
e = fmt.Errorf("failed to modify %s due to %s error: %s", objectType, err.Type, err.Description)
|
||||
}
|
||||
return SimpleError{code: JmapErrorSetError, err: e}
|
||||
}
|
||||
651
pkg/jmap/jmap_http.go
Normal file
651
pkg/jmap/jmap_http.go
Normal file
@@ -0,0 +1,651 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
)
|
||||
|
||||
// Implementation of ApiClient, SessionClient and BlobClient that uses
|
||||
// HTTP to perform JMAP operations.
|
||||
type HttpJmapClient struct {
|
||||
client *http.Client
|
||||
masterUser string
|
||||
masterPassword string
|
||||
userAgent string
|
||||
listener HttpJmapApiClientEventListener
|
||||
}
|
||||
|
||||
var (
|
||||
_ ApiClient = &HttpJmapClient{}
|
||||
_ SessionClient = &HttpJmapClient{}
|
||||
_ BlobClient = &HttpJmapClient{}
|
||||
)
|
||||
|
||||
const (
|
||||
logEndpoint = "endpoint"
|
||||
logHttpStatus = "status"
|
||||
logHttpStatusCode = "status-code"
|
||||
logHttpUrl = "url"
|
||||
logProto = "proto"
|
||||
logProtoJmap = "jmap"
|
||||
logProtoJmapWs = "jmapws"
|
||||
logType = "type"
|
||||
logTypeRequest = "request"
|
||||
logTypeResponse = "response"
|
||||
logTypePush = "push"
|
||||
)
|
||||
|
||||
/*
|
||||
func bearer(req *http.Request, token string) {
|
||||
req.Header.Add("Authorization", "Bearer "+base64.StdEncoding.EncodeToString([]byte(token)))
|
||||
}
|
||||
*/
|
||||
|
||||
// Record JMAP HTTP execution events that may occur, e.g. using metrics.
|
||||
type HttpJmapApiClientEventListener interface {
|
||||
OnSuccessfulRequest(endpoint string, status int)
|
||||
OnFailedRequest(endpoint string, err error)
|
||||
OnFailedRequestWithStatus(endpoint string, status int)
|
||||
OnResponseBodyReadingError(endpoint string, err error)
|
||||
OnResponseBodyUnmarshallingError(endpoint string, err error)
|
||||
OnSuccessfulWsRequest(endpoint string, status int)
|
||||
OnFailedWsHandshakeRequestWithStatus(endpoint string, status int)
|
||||
}
|
||||
|
||||
type nullHttpJmapApiClientEventListener struct {
|
||||
}
|
||||
|
||||
func (l nullHttpJmapApiClientEventListener) OnSuccessfulRequest(endpoint string, status int) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnFailedRequest(endpoint string, err error) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnFailedRequestWithStatus(endpoint string, status int) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnResponseBodyReadingError(endpoint string, err error) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnResponseBodyUnmarshallingError(endpoint string, err error) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnSuccessfulWsRequest(endpoint string, status int) {
|
||||
}
|
||||
func (l nullHttpJmapApiClientEventListener) OnFailedWsHandshakeRequestWithStatus(endpoint string, status int) {
|
||||
}
|
||||
|
||||
var _ HttpJmapApiClientEventListener = nullHttpJmapApiClientEventListener{}
|
||||
|
||||
// An implementation of HttpJmapApiClientMetricsRecorder that does nothing.
|
||||
func NullHttpJmapApiClientEventListener() HttpJmapApiClientEventListener {
|
||||
return nullHttpJmapApiClientEventListener{}
|
||||
}
|
||||
|
||||
func NewHttpJmapClient(client *http.Client, masterUser string, masterPassword string, listener HttpJmapApiClientEventListener) *HttpJmapClient {
|
||||
return &HttpJmapClient{
|
||||
client: client,
|
||||
masterUser: masterUser,
|
||||
masterPassword: masterPassword,
|
||||
userAgent: "OpenCloud/" + version.GetString(),
|
||||
listener: listener,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HttpJmapClient) Close() error {
|
||||
h.client.CloseIdleConnections()
|
||||
return nil
|
||||
}
|
||||
|
||||
type AuthenticationError struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e AuthenticationError) Error() string {
|
||||
return fmt.Sprintf("failed to find user for authentication: %v", e.Err.Error())
|
||||
}
|
||||
func (e AuthenticationError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
func (h *HttpJmapClient) auth(username string, _ *log.Logger, req *http.Request) error {
|
||||
masterUsername := username + "%" + h.masterUser
|
||||
req.SetBasicAuth(masterUsername, h.masterPassword)
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
errNilBaseUrl = errors.New("sessionUrl is nil")
|
||||
)
|
||||
|
||||
func (h *HttpJmapClient) GetSession(sessionUrl *url.URL, username string, logger *log.Logger) (SessionResponse, Error) {
|
||||
if sessionUrl == nil {
|
||||
logger.Error().Msg("sessionUrl is nil")
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorInvalidHttpRequest, err: errNilBaseUrl}
|
||||
}
|
||||
// See the JMAP specification on Service Autodiscovery: https://jmap.io/spec-core.html#service-autodiscovery
|
||||
// There are two standardised autodiscovery methods in use for Internet protocols:
|
||||
// - DNS SRV (see [@!RFC2782], [@!RFC6186], and [@!RFC6764])
|
||||
// - .well-known/servicename (see [@!RFC8615])
|
||||
// We are currently only supporting RFC8615, using the baseurl that was configured in this HttpJmapApiClient.
|
||||
//sessionUrl := baseurl.JoinPath(".well-known", "jmap")
|
||||
sessionUrlStr := sessionUrl.String()
|
||||
endpoint := endpointOf(sessionUrl)
|
||||
logger = log.From(logger.With().Str(logEndpoint, endpoint))
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, sessionUrlStr, nil)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to create GET request for %v", sessionUrl)
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorInvalidHttpRequest, err: err}
|
||||
}
|
||||
h.auth(username, logger, req)
|
||||
req.Header.Add("Cache-Control", "no-cache, no-store, must-revalidate") // spec recommendation
|
||||
|
||||
res, err := h.client.Do(req)
|
||||
if err != nil {
|
||||
h.listener.OnFailedRequest(endpoint, err)
|
||||
logger.Error().Err(err).Msgf("failed to perform GET %v", sessionUrl)
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorInvalidHttpRequest, err: err}
|
||||
}
|
||||
if res.StatusCode < 200 || res.StatusCode > 299 {
|
||||
h.listener.OnFailedRequestWithStatus(endpoint, res.StatusCode)
|
||||
logger.Error().Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).Msg("HTTP response status code is not 200")
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorServerResponse, err: fmt.Errorf("JMAP API response status is %v", res.Status)}
|
||||
}
|
||||
h.listener.OnSuccessfulRequest(endpoint, res.StatusCode)
|
||||
|
||||
if res.Body != nil {
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to close response body")
|
||||
}
|
||||
}(res.Body)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to read response body")
|
||||
h.listener.OnResponseBodyReadingError(endpoint, err)
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorReadingResponseBody, err: err}
|
||||
}
|
||||
|
||||
var data SessionResponse
|
||||
err = json.Unmarshal(body, &data)
|
||||
if err != nil {
|
||||
logger.Error().Str(logHttpUrl, log.SafeString(sessionUrlStr)).Err(err).Msg("failed to decode JSON payload from .well-known/jmap response")
|
||||
h.listener.OnResponseBodyUnmarshallingError(endpoint, err)
|
||||
return SessionResponse{}, SimpleError{code: JmapErrorDecodingResponseBody, err: err}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (h *HttpJmapClient) Command(ctx context.Context, logger *log.Logger, session *Session, request Request, acceptLanguage string) ([]byte, Language, Error) {
|
||||
jmapUrl := session.JmapUrl.String()
|
||||
endpoint := session.JmapEndpoint
|
||||
logger = log.From(logger.With().Str(logEndpoint, endpoint))
|
||||
|
||||
bodyBytes, err := json.Marshal(request)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to marshall JSON payload")
|
||||
return nil, "", SimpleError{code: JmapErrorEncodingRequestBody, err: err}
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, jmapUrl, bytes.NewBuffer(bodyBytes))
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to create POST request for %v", jmapUrl)
|
||||
return nil, "", SimpleError{code: JmapErrorCreatingRequest, err: err}
|
||||
}
|
||||
|
||||
// Some JMAP APIs use the Accept-Language header to determine which language to use to translate
|
||||
// texts in attributes.
|
||||
if acceptLanguage != "" {
|
||||
req.Header.Add("Accept-Language", acceptLanguage)
|
||||
}
|
||||
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("User-Agent", h.userAgent)
|
||||
|
||||
if logger.Trace().Enabled() {
|
||||
requestBytes, err := httputil.DumpRequestOut(req, true)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeRequest).Msg(string(requestBytes))
|
||||
}
|
||||
}
|
||||
h.auth(session.Username, logger, req)
|
||||
|
||||
res, err := h.client.Do(req)
|
||||
if err != nil {
|
||||
h.listener.OnFailedRequest(endpoint, err)
|
||||
logger.Error().Err(err).Msgf("failed to perform POST %v", jmapUrl)
|
||||
return nil, "", SimpleError{code: JmapErrorSendingRequest, err: err}
|
||||
}
|
||||
|
||||
if logger.Trace().Enabled() {
|
||||
responseBytes, err := httputil.DumpResponse(res, true)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeResponse).
|
||||
Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).
|
||||
Msg(string(responseBytes))
|
||||
}
|
||||
}
|
||||
|
||||
language := Language(res.Header.Get("Content-Language"))
|
||||
if res.StatusCode < 200 || res.StatusCode > 299 {
|
||||
h.listener.OnFailedRequestWithStatus(endpoint, res.StatusCode)
|
||||
logger.Error().Str(logEndpoint, endpoint).Str(logHttpStatus, log.SafeString(res.Status)).Msg("HTTP response status code is not 2xx")
|
||||
return nil, language, SimpleError{code: JmapErrorServerResponse, err: err}
|
||||
}
|
||||
if res.Body != nil {
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to close response body")
|
||||
}
|
||||
}(res.Body)
|
||||
}
|
||||
h.listener.OnSuccessfulRequest(endpoint, res.StatusCode)
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to read response body")
|
||||
h.listener.OnResponseBodyReadingError(endpoint, err)
|
||||
return nil, language, SimpleError{code: JmapErrorServerResponse, err: err}
|
||||
}
|
||||
|
||||
return body, language, nil
|
||||
}
|
||||
|
||||
func (h *HttpJmapClient) UploadBinary(ctx context.Context, logger *log.Logger, session *Session, uploadUrl string, endpoint string, contentType string, acceptLanguage string, body io.Reader) (UploadedBlob, Language, Error) {
|
||||
logger = log.From(logger.With().Str(logEndpoint, endpoint))
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, uploadUrl, body)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to create POST request for %v", uploadUrl)
|
||||
return UploadedBlob{}, "", SimpleError{code: JmapErrorCreatingRequest, err: err}
|
||||
}
|
||||
req.Header.Add("Content-Type", contentType)
|
||||
req.Header.Add("User-Agent", h.userAgent)
|
||||
if acceptLanguage != "" {
|
||||
req.Header.Add("Accept-Language", acceptLanguage)
|
||||
}
|
||||
if logger.Trace().Enabled() {
|
||||
requestBytes, err := httputil.DumpRequestOut(req, false)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeRequest).Msg(string(requestBytes))
|
||||
}
|
||||
}
|
||||
|
||||
h.auth(session.Username, logger, req)
|
||||
|
||||
res, err := h.client.Do(req)
|
||||
if err != nil {
|
||||
h.listener.OnFailedRequest(endpoint, err)
|
||||
logger.Error().Err(err).Msgf("failed to perform POST %v", uploadUrl)
|
||||
return UploadedBlob{}, "", SimpleError{code: JmapErrorSendingRequest, err: err}
|
||||
}
|
||||
if logger.Trace().Enabled() {
|
||||
responseBytes, err := httputil.DumpResponse(res, true)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeResponse).
|
||||
Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).
|
||||
Msg(string(responseBytes))
|
||||
}
|
||||
}
|
||||
|
||||
language := Language(res.Header.Get("Content-Language"))
|
||||
if res.StatusCode < 200 || res.StatusCode > 299 {
|
||||
h.listener.OnFailedRequestWithStatus(endpoint, res.StatusCode)
|
||||
logger.Error().Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).Msg("HTTP response status code is not 2xx")
|
||||
return UploadedBlob{}, language, SimpleError{code: JmapErrorServerResponse, err: err}
|
||||
}
|
||||
if res.Body != nil {
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to close response body")
|
||||
}
|
||||
}(res.Body)
|
||||
}
|
||||
h.listener.OnSuccessfulRequest(endpoint, res.StatusCode)
|
||||
|
||||
responseBody, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("failed to read response body")
|
||||
h.listener.OnResponseBodyReadingError(endpoint, err)
|
||||
return UploadedBlob{}, language, SimpleError{code: JmapErrorServerResponse, err: err}
|
||||
}
|
||||
|
||||
logger.Trace()
|
||||
|
||||
var result UploadedBlob
|
||||
err = json.Unmarshal(responseBody, &result)
|
||||
if err != nil {
|
||||
logger.Error().Str(logHttpUrl, log.SafeString(uploadUrl)).Err(err).Msg("failed to decode JSON payload from the upload response")
|
||||
h.listener.OnResponseBodyUnmarshallingError(endpoint, err)
|
||||
return UploadedBlob{}, language, SimpleError{code: JmapErrorDecodingResponseBody, err: err}
|
||||
}
|
||||
|
||||
return result, language, nil
|
||||
}
|
||||
|
||||
func (h *HttpJmapClient) DownloadBinary(ctx context.Context, logger *log.Logger, session *Session, downloadUrl string, endpoint string, acceptLanguage string) (*BlobDownload, Language, Error) {
|
||||
logger = log.From(logger.With().Str(logEndpoint, endpoint))
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, downloadUrl, nil)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to create GET request for %v", downloadUrl)
|
||||
return nil, "", SimpleError{code: JmapErrorCreatingRequest, err: err}
|
||||
}
|
||||
req.Header.Add("User-Agent", h.userAgent)
|
||||
if acceptLanguage != "" {
|
||||
req.Header.Add("Accept-Language", acceptLanguage)
|
||||
}
|
||||
if logger.Trace().Enabled() {
|
||||
requestBytes, err := httputil.DumpRequestOut(req, true)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeRequest).Msg(string(requestBytes))
|
||||
}
|
||||
}
|
||||
h.auth(session.Username, logger, req)
|
||||
|
||||
res, err := h.client.Do(req)
|
||||
if err != nil {
|
||||
h.listener.OnFailedRequest(endpoint, err)
|
||||
logger.Error().Err(err).Msgf("failed to perform GET %v", downloadUrl)
|
||||
return nil, "", SimpleError{code: JmapErrorSendingRequest, err: err}
|
||||
}
|
||||
if logger.Trace().Enabled() {
|
||||
responseBytes, err := httputil.DumpResponse(res, false)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmap).Str(logType, logTypeResponse).
|
||||
Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).
|
||||
Msg(string(responseBytes))
|
||||
}
|
||||
}
|
||||
language := Language(res.Header.Get("Content-Language"))
|
||||
if res.StatusCode == http.StatusNotFound {
|
||||
return nil, language, nil
|
||||
}
|
||||
if res.StatusCode < 200 || res.StatusCode > 299 {
|
||||
h.listener.OnFailedRequestWithStatus(endpoint, res.StatusCode)
|
||||
logger.Error().Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).Msg("HTTP response status code is not 2xx")
|
||||
return nil, language, SimpleError{code: JmapErrorServerResponse, err: err}
|
||||
}
|
||||
h.listener.OnSuccessfulRequest(endpoint, res.StatusCode)
|
||||
|
||||
sizeStr := res.Header.Get("Content-Length")
|
||||
size := -1
|
||||
if sizeStr != "" {
|
||||
size, err = strconv.Atoi(sizeStr)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Msgf("failed to parse Content-Length blob download response header value '%v'", sizeStr)
|
||||
size = -1
|
||||
}
|
||||
}
|
||||
|
||||
return &BlobDownload{
|
||||
Body: res.Body,
|
||||
Size: size,
|
||||
Type: res.Header.Get("Content-Type"),
|
||||
ContentDisposition: res.Header.Get("Content-Disposition"),
|
||||
CacheControl: res.Header.Get("Cache-Control"),
|
||||
}, language, nil
|
||||
}
|
||||
|
||||
type WebSocketPushEnableType string
|
||||
type WebSocketPushDisableType string
|
||||
|
||||
const (
|
||||
WebSocketPushTypeEnable = WebSocketPushEnableType("WebSocketPushEnable")
|
||||
WebSocketPushTypeDisable = WebSocketPushDisableType("WebSocketPushDisable")
|
||||
)
|
||||
|
||||
type WebSocketPushEnable struct {
|
||||
// This MUST be the string "WebSocketPushEnable".
|
||||
Type WebSocketPushEnableType `json:"@type"`
|
||||
|
||||
// A list of data type names (e.g., "Mailbox" or "Email") that the client is interested in.
|
||||
//
|
||||
// A StateChange notification will only be sent if the data for one of these types changes.
|
||||
// Other types are omitted from the TypeState object.
|
||||
//
|
||||
// If null, changes will be pushed for all supported data types.
|
||||
DataTypes *[]string `json:"dataTypes"`
|
||||
|
||||
// The last "pushState" token that the client received from the server.
|
||||
|
||||
// Upon receipt of a "pushState" token, the server SHOULD immediately send all changes since that state token.
|
||||
PushState State `json:"pushState,omitempty"`
|
||||
}
|
||||
|
||||
type WebSocketPushDisable struct {
|
||||
// This MUST be the string "WebSocketPushDisable".
|
||||
Type WebSocketPushDisableType `json:"@type"`
|
||||
}
|
||||
|
||||
type HttpWsClientFactory struct {
|
||||
dialer *websocket.Dialer
|
||||
masterUser string
|
||||
masterPassword string
|
||||
logger *log.Logger
|
||||
eventListener HttpJmapApiClientEventListener
|
||||
}
|
||||
|
||||
var _ WsClientFactory = &HttpWsClientFactory{}
|
||||
|
||||
func NewHttpWsClientFactory(dialer *websocket.Dialer, masterUser string, masterPassword string, logger *log.Logger,
|
||||
eventListener HttpJmapApiClientEventListener) (*HttpWsClientFactory, error) {
|
||||
// RFC 8887: Section 4.2:
|
||||
// Otherwise, the client MUST make an authenticated HTTP request [RFC7235] on the encrypted connection
|
||||
// and MUST include the value "jmap" in the list of protocols for the "Sec-WebSocket-Protocol" header
|
||||
// field.
|
||||
dialer.Subprotocols = []string{"jmap"}
|
||||
|
||||
return &HttpWsClientFactory{
|
||||
dialer: dialer,
|
||||
masterUser: masterUser,
|
||||
masterPassword: masterPassword,
|
||||
logger: logger,
|
||||
eventListener: eventListener,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (w *HttpWsClientFactory) auth(username string, h http.Header) error {
|
||||
masterUsername := username + "%" + w.masterUser
|
||||
h.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(masterUsername+":"+w.masterPassword)))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *HttpWsClientFactory) connect(sessionProvider func() (*Session, error)) (*websocket.Conn, string, string, Error) {
|
||||
logger := w.logger
|
||||
|
||||
session, err := sessionProvider()
|
||||
if err != nil {
|
||||
return nil, "", "", SimpleError{code: JmapErrorWssFailedToRetrieveSession, err: err}
|
||||
}
|
||||
if session == nil {
|
||||
return nil, "", "", SimpleError{code: JmapErrorWssFailedToRetrieveSession, err: nil}
|
||||
}
|
||||
|
||||
if !session.SupportsWebsocketPush {
|
||||
return nil, "", "", SimpleError{code: JmapErrorSocketPushUnsupported, err: nil}
|
||||
}
|
||||
|
||||
username := session.Username
|
||||
u := session.WebsocketUrl
|
||||
endpoint := session.WebsocketEndpoint
|
||||
|
||||
ctx := context.Background() // TODO WS connection context with a timeout?
|
||||
|
||||
h := http.Header{}
|
||||
w.auth(username, h)
|
||||
c, res, err := w.dialer.DialContext(ctx, u.String(), h)
|
||||
if err != nil {
|
||||
return nil, "", endpoint, SimpleError{code: JmapErrorFailedToEstablishWssConnection, err: err}
|
||||
}
|
||||
|
||||
if w.logger.Trace().Enabled() {
|
||||
responseBytes, err := httputil.DumpResponse(res, true)
|
||||
if err == nil {
|
||||
logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmapWs).Str(logType, logTypeResponse).
|
||||
Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).
|
||||
Msg(string(responseBytes))
|
||||
}
|
||||
}
|
||||
|
||||
if res.StatusCode != 101 {
|
||||
w.eventListener.OnFailedRequestWithStatus(endpoint, res.StatusCode)
|
||||
logger.Error().Str(logHttpStatus, log.SafeString(res.Status)).Int(logHttpStatusCode, res.StatusCode).Msg("HTTP response status code is not 101")
|
||||
return nil, "", endpoint, SimpleError{code: JmapErrorServerResponse, err: fmt.Errorf("JMAP WS API response status is %v", res.Status)}
|
||||
} else {
|
||||
w.eventListener.OnSuccessfulWsRequest(endpoint, res.StatusCode)
|
||||
}
|
||||
|
||||
// RFC 8887: Section 4.2:
|
||||
// The reply from the server MUST also contain a corresponding "Sec-WebSocket-Protocol" header
|
||||
// field with a value of "jmap" in order for a JMAP subprotocol connection to be established.
|
||||
if !slices.Contains(res.Header.Values("Sec-WebSocket-Protocol"), "jmap") {
|
||||
return nil, "", endpoint, SimpleError{code: JmapErrorWssConnectionResponseMissingJmapSubprotocol}
|
||||
}
|
||||
|
||||
return c, username, endpoint, nil
|
||||
}
|
||||
|
||||
type HttpWsClient struct {
|
||||
client *HttpWsClientFactory
|
||||
username string
|
||||
sessionProvider func() (*Session, error)
|
||||
c *websocket.Conn
|
||||
logger *log.Logger
|
||||
endpoint string
|
||||
listener WsPushListener
|
||||
WsClient
|
||||
}
|
||||
|
||||
func (w *HttpWsClient) readPump() {
|
||||
defer func() {
|
||||
w.c.Close()
|
||||
}()
|
||||
//w.c.SetReadLimit(maxMessageSize)
|
||||
//c.conn.SetReadDeadline(time.Now().Add(pongWait))
|
||||
//c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
|
||||
|
||||
logger := log.From(w.logger.With().Str("username", w.username))
|
||||
|
||||
for {
|
||||
if _, message, err := w.c.ReadMessage(); err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
logger.Error().Err(err).Msg("unexpected close")
|
||||
}
|
||||
break
|
||||
} else {
|
||||
if logger.Trace().Enabled() {
|
||||
logger.Trace().Str(logEndpoint, w.endpoint).Str(logProto, logProtoJmapWs).Str(logType, logTypePush).Msg(string(message))
|
||||
}
|
||||
|
||||
var peek struct {
|
||||
Type string `json:"@type"`
|
||||
}
|
||||
if err := json.Unmarshal(message, &peek); err != nil {
|
||||
logger.Error().Err(err).Msg("failed to deserialized pushed WS message")
|
||||
continue
|
||||
}
|
||||
switch peek.Type {
|
||||
case string(TypeOfStateChange):
|
||||
var stateChange StateChange
|
||||
if err := json.Unmarshal(message, &stateChange); err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to deserialized pushed WS message into a %T", stateChange)
|
||||
continue
|
||||
} else {
|
||||
if w.listener != nil {
|
||||
w.listener.OnNotification(w.username, stateChange)
|
||||
} else {
|
||||
logger.Warn().Msgf("no listener to be notified of %v", stateChange)
|
||||
}
|
||||
}
|
||||
default:
|
||||
logger.Warn().Msgf("unsupported pushed WS message JMAP @type: '%s'", peek.Type)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *HttpWsClientFactory) EnableNotifications(pushState State, sessionProvider func() (*Session, error), listener WsPushListener) (WsClient, Error) {
|
||||
c, username, endpoint, jerr := w.connect(sessionProvider)
|
||||
if jerr != nil {
|
||||
return nil, jerr
|
||||
}
|
||||
|
||||
msg := WebSocketPushEnable{
|
||||
Type: WebSocketPushTypeEnable,
|
||||
DataTypes: nil, // = all datatypes
|
||||
PushState: pushState, // will be omitted if empty string
|
||||
}
|
||||
|
||||
data, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return nil, SimpleError{code: JmapErrorWssFailedToSendWebSocketPushEnable, err: err}
|
||||
}
|
||||
|
||||
if w.logger.Trace().Enabled() {
|
||||
w.logger.Trace().Str(logEndpoint, endpoint).Str(logProto, logProtoJmapWs).Str(logType, logTypeRequest).Msg(string(data))
|
||||
}
|
||||
if err := c.WriteMessage(websocket.TextMessage, data); err != nil {
|
||||
return nil, SimpleError{code: JmapErrorWssFailedToSendWebSocketPushEnable, err: err}
|
||||
}
|
||||
|
||||
wsc := &HttpWsClient{
|
||||
client: w,
|
||||
username: username,
|
||||
sessionProvider: sessionProvider,
|
||||
c: c,
|
||||
logger: w.logger,
|
||||
endpoint: endpoint,
|
||||
listener: listener,
|
||||
}
|
||||
|
||||
go wsc.readPump()
|
||||
|
||||
return wsc, nil
|
||||
}
|
||||
|
||||
func (w *HttpWsClientFactory) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *HttpWsClient) DisableNotifications() Error {
|
||||
if c.c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
werr := c.c.WriteJSON(WebSocketPushDisable{Type: WebSocketPushTypeDisable})
|
||||
merr := c.c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
|
||||
cerr := c.c.Close()
|
||||
|
||||
if werr != nil {
|
||||
return SimpleError{code: JmapErrorWssFailedToClose, err: werr}
|
||||
}
|
||||
if merr != nil {
|
||||
return SimpleError{code: JmapErrorWssFailedToClose, err: merr}
|
||||
}
|
||||
if cerr != nil {
|
||||
return SimpleError{code: JmapErrorWssFailedToClose, err: cerr}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *HttpWsClient) Close() error {
|
||||
return c.DisableNotifications()
|
||||
}
|
||||
494
pkg/jmap/jmap_integration_contact_test.go
Normal file
494
pkg/jmap/jmap_integration_contact_test.go
Normal file
@@ -0,0 +1,494 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp"
|
||||
"github.com/brianvoe/gofakeit/v7"
|
||||
"github.com/opencloud-eu/opencloud/pkg/jscontact"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
// currently not supported, reported as https://github.com/stalwartlabs/stalwart/issues/2431
|
||||
EnableMediaWithBlobId = false
|
||||
)
|
||||
|
||||
func TestContacts(t *testing.T) {
|
||||
if skip(t) {
|
||||
return
|
||||
}
|
||||
|
||||
count := uint(20 + rand.Intn(30))
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
s, err := newStalwartTest(t)
|
||||
require.NoError(err)
|
||||
defer s.Close()
|
||||
|
||||
user := pickUser()
|
||||
session := s.Session(user.name)
|
||||
|
||||
accountId, addressbookId, expectedContactCardsById, boxes, err := s.fillContacts(t, count, session, user)
|
||||
require.NoError(err)
|
||||
require.NotEmpty(accountId)
|
||||
require.NotEmpty(addressbookId)
|
||||
|
||||
filter := ContactCardFilterCondition{
|
||||
InAddressBook: addressbookId,
|
||||
}
|
||||
sortBy := []ContactCardComparator{
|
||||
{Property: jscontact.ContactCardPropertyCreated, IsAscending: true},
|
||||
}
|
||||
|
||||
contactsByAccount, _, _, _, err := s.client.QueryContactCards([]string{accountId}, session, t.Context(), s.logger, "", filter, sortBy, 0, 0)
|
||||
require.NoError(err)
|
||||
|
||||
require.Len(contactsByAccount, 1)
|
||||
require.Contains(contactsByAccount, accountId)
|
||||
contacts := contactsByAccount[accountId]
|
||||
require.Len(contacts, int(count))
|
||||
|
||||
for _, actual := range contacts {
|
||||
expected, ok := expectedContactCardsById[actual.Id]
|
||||
require.True(ok, "failed to find created contact by its id")
|
||||
matchContact(t, actual, expected)
|
||||
}
|
||||
|
||||
exceptions := []string{}
|
||||
if !EnableMediaWithBlobId {
|
||||
exceptions = append(exceptions, "mediaWithBlobId")
|
||||
}
|
||||
allBoxesAreTicked(t, boxes, exceptions...)
|
||||
}
|
||||
|
||||
func matchContact(t *testing.T, actual jscontact.ContactCard, expected jscontact.ContactCard) {
|
||||
// require.Equal(t, expected, actual)
|
||||
deepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
type ContactsBoxes struct {
|
||||
nicknames bool
|
||||
secondaryEmails bool
|
||||
secondaryAddress bool
|
||||
phones bool
|
||||
onlineService bool
|
||||
preferredLanguage bool
|
||||
mediaWithBlobId bool
|
||||
mediaWithDataUri bool
|
||||
mediaWithExternalUri bool
|
||||
organization bool
|
||||
cryptoKey bool
|
||||
link bool
|
||||
}
|
||||
|
||||
var streetNumberRegex = regexp.MustCompile(`^(\d+)\s+(.+)$`)
|
||||
|
||||
func (s *StalwartTest) fillContacts(
|
||||
t *testing.T,
|
||||
count uint,
|
||||
session *Session,
|
||||
user User,
|
||||
) (string, string, map[string]jscontact.ContactCard, ContactsBoxes, error) {
|
||||
require := require.New(t)
|
||||
c, err := NewTestJmapClient(session, user.name, user.password, true, true)
|
||||
require.NoError(err)
|
||||
defer c.Close()
|
||||
|
||||
boxes := ContactsBoxes{}
|
||||
|
||||
printer := func(s string) { log.Println(s) }
|
||||
|
||||
accountId := c.session.PrimaryAccounts.Contacts
|
||||
require.NotEmpty(accountId, "no primary account for contacts in session")
|
||||
|
||||
addressbookId := ""
|
||||
{
|
||||
addressBooksById, err := c.objectsById(accountId, AddressBookType, JmapContacts)
|
||||
require.NoError(err)
|
||||
|
||||
for id, addressbook := range addressBooksById {
|
||||
if isDefault, ok := addressbook["isDefault"]; ok {
|
||||
if isDefault.(bool) {
|
||||
addressbookId = id
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
require.NotEmpty(addressbookId)
|
||||
|
||||
filled := map[string]jscontact.ContactCard{}
|
||||
for i := range count {
|
||||
person := gofakeit.Person()
|
||||
nameMap, nameObj := createName(person)
|
||||
language := pickLanguage()
|
||||
contact := map[string]any{
|
||||
"@type": "Card",
|
||||
"version": "1.0",
|
||||
"addressBookIds": toBoolMap([]string{addressbookId}),
|
||||
"prodId": productName,
|
||||
"language": language,
|
||||
"kind": "individual",
|
||||
"name": nameMap,
|
||||
}
|
||||
card := jscontact.ContactCard{
|
||||
Type: jscontact.ContactCardType,
|
||||
Version: "1.0",
|
||||
AddressBookIds: toBoolMap([]string{addressbookId}),
|
||||
ProdId: productName,
|
||||
Language: language,
|
||||
Kind: jscontact.ContactCardKindIndividual,
|
||||
Name: &nameObj,
|
||||
}
|
||||
|
||||
if i%3 == 0 {
|
||||
nicknameMap, nicknameObj := createNickName(person)
|
||||
id := id()
|
||||
contact["nicknames"] = map[string]map[string]any{id: nicknameMap}
|
||||
card.Nicknames = map[string]jscontact.Nickname{id: nicknameObj}
|
||||
boxes.nicknames = true
|
||||
}
|
||||
|
||||
{
|
||||
emailMaps := map[string]map[string]any{}
|
||||
emailObjs := map[string]jscontact.EmailAddress{}
|
||||
emailId := id()
|
||||
emailMap, emailObj := createEmail(person, 10)
|
||||
emailMaps[emailId] = emailMap
|
||||
emailObjs[emailId] = emailObj
|
||||
|
||||
for i := range rand.Intn(3) {
|
||||
id := id()
|
||||
m, o := createSecondaryEmail(gofakeit.Email(), i*100)
|
||||
emailMaps[id] = m
|
||||
emailObjs[id] = o
|
||||
boxes.secondaryEmails = true
|
||||
}
|
||||
if len(emailMaps) > 0 {
|
||||
contact["emails"] = emailMaps
|
||||
card.Emails = emailObjs
|
||||
}
|
||||
}
|
||||
if err := propmap(i%2 == 0, 1, 2, contact, "phones", &card.Phones, func(i int, id string) (map[string]any, jscontact.Phone, error) {
|
||||
boxes.phones = true
|
||||
num := person.Contact.Phone
|
||||
if i > 0 {
|
||||
num = gofakeit.Phone()
|
||||
}
|
||||
var features map[jscontact.PhoneFeature]bool = nil
|
||||
if rand.Intn(3) < 2 {
|
||||
features = toBoolMapS(jscontact.PhoneFeatureMobile, jscontact.PhoneFeatureVoice, jscontact.PhoneFeatureVideo, jscontact.PhoneFeatureText)
|
||||
} else {
|
||||
features = toBoolMapS(jscontact.PhoneFeatureVoice, jscontact.PhoneFeatureMainNumber)
|
||||
}
|
||||
|
||||
contexts := map[jscontact.PhoneContext]bool{jscontact.PhoneContextWork: true}
|
||||
if rand.Intn(2) < 1 {
|
||||
contexts[jscontact.PhoneContextPrivate] = true
|
||||
}
|
||||
tel := "tel:" + "+1" + num
|
||||
return map[string]any{
|
||||
"@type": "Phone",
|
||||
"number": tel,
|
||||
"features": structs.MapKeys(features, func(f jscontact.PhoneFeature) string { return string(f) }),
|
||||
"contexts": structs.MapKeys(contexts, func(c jscontact.PhoneContext) string { return string(c) }),
|
||||
}, jscontact.Phone{
|
||||
Type: jscontact.PhoneType,
|
||||
Number: tel,
|
||||
Features: features,
|
||||
Contexts: contexts,
|
||||
}, nil
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
if err := propmap(i%5 < 4, 1, 2, contact, "addresses", &card.Addresses, func(i int, id string) (map[string]any, jscontact.Address, error) {
|
||||
var source *gofakeit.AddressInfo
|
||||
if i == 0 {
|
||||
source = person.Address
|
||||
} else {
|
||||
source = gofakeit.Address()
|
||||
boxes.secondaryAddress = true
|
||||
}
|
||||
components := []jscontact.AddressComponent{}
|
||||
m := streetNumberRegex.FindAllStringSubmatch(source.Street, -1)
|
||||
if m != nil {
|
||||
components = append(components, jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindName, Value: m[0][2]})
|
||||
components = append(components, jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindNumber, Value: m[0][1]})
|
||||
} else {
|
||||
components = append(components, jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindName, Value: source.Street})
|
||||
}
|
||||
components = append(components,
|
||||
jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindLocality, Value: source.City},
|
||||
jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindCountry, Value: source.Country},
|
||||
jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindRegion, Value: source.State},
|
||||
jscontact.AddressComponent{Type: jscontact.AddressComponentType, Kind: jscontact.AddressComponentKindPostcode, Value: source.Zip},
|
||||
)
|
||||
tz := pickRandom(timezones...)
|
||||
return map[string]any{
|
||||
"@type": "Address",
|
||||
"components": structs.Map(components, func(c jscontact.AddressComponent) map[string]string {
|
||||
return map[string]string{"kind": string(c.Kind), "value": c.Value}
|
||||
}),
|
||||
"defaultSeparator": ", ",
|
||||
"isOrdered": true,
|
||||
"timeZone": tz,
|
||||
}, jscontact.Address{
|
||||
Type: jscontact.AddressType,
|
||||
Components: components,
|
||||
DefaultSeparator: ", ",
|
||||
IsOrdered: true,
|
||||
TimeZone: tz,
|
||||
}, nil
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
if err := propmap(i%2 == 0, 1, 2, contact, "onlineServices", &card.OnlineServices, func(i int, id string) (map[string]any, jscontact.OnlineService, error) {
|
||||
boxes.onlineService = true
|
||||
switch rand.Intn(3) {
|
||||
case 0:
|
||||
return map[string]any{
|
||||
"@type": "OnlineService",
|
||||
"service": "Mastodon",
|
||||
"user": "@" + person.Contact.Email,
|
||||
"uri": "https://mastodon.example.com/@" + strings.ToLower(person.FirstName),
|
||||
}, jscontact.OnlineService{
|
||||
Type: jscontact.OnlineServiceType,
|
||||
Service: "Mastodon",
|
||||
User: "@" + person.Contact.Email,
|
||||
Uri: "https://mastodon.example.com/@" + strings.ToLower(person.FirstName),
|
||||
}, nil
|
||||
case 1:
|
||||
return map[string]any{
|
||||
"@type": "OnlineService",
|
||||
"uri": "xmpp:" + person.Contact.Email,
|
||||
}, jscontact.OnlineService{
|
||||
Type: jscontact.OnlineServiceType,
|
||||
Uri: "xmpp:" + person.Contact.Email,
|
||||
}, nil
|
||||
default:
|
||||
return map[string]any{
|
||||
"@type": "OnlineService",
|
||||
"service": "Discord",
|
||||
"user": person.Contact.Email,
|
||||
"uri": "https://discord.example.com/user/" + person.Contact.Email,
|
||||
}, jscontact.OnlineService{
|
||||
Type: jscontact.OnlineServiceType,
|
||||
Service: "Discord",
|
||||
User: person.Contact.Email,
|
||||
Uri: "https://discord.example.com/user/" + person.Contact.Email,
|
||||
}, nil
|
||||
}
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
|
||||
if err := propmap(i%3 == 0, 1, 2, contact, "preferredLanguages", &card.PreferredLanguages, func(i int, id string) (map[string]any, jscontact.LanguagePref, error) {
|
||||
boxes.preferredLanguage = true
|
||||
lang := pickRandom("en", "fr", "de", "es", "it")
|
||||
contexts := pickRandoms1("work", "private")
|
||||
return map[string]any{
|
||||
"@type": "LanguagePref",
|
||||
"language": lang,
|
||||
"contexts": toBoolMap(contexts),
|
||||
"pref": i + 1,
|
||||
}, jscontact.LanguagePref{
|
||||
Type: jscontact.LanguagePrefType,
|
||||
Language: lang,
|
||||
Contexts: toBoolMap(structs.Map(contexts, func(s string) jscontact.LanguagePrefContext { return jscontact.LanguagePrefContext(s) })),
|
||||
Pref: uint(i + 1),
|
||||
}, nil
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
|
||||
if i%2 == 0 {
|
||||
organizationMaps := map[string]map[string]any{}
|
||||
organizationObjs := map[string]jscontact.Organization{}
|
||||
titleMaps := map[string]map[string]any{}
|
||||
titleObjs := map[string]jscontact.Title{}
|
||||
for range 1 + rand.Intn(2) {
|
||||
boxes.organization = true
|
||||
orgId := id()
|
||||
titleId := id()
|
||||
organizationMaps[orgId] = map[string]any{
|
||||
"@type": "Organization",
|
||||
"name": person.Job.Company,
|
||||
"contexts": toBoolMapS("work"),
|
||||
}
|
||||
organizationObjs[orgId] = jscontact.Organization{
|
||||
Type: jscontact.OrganizationType,
|
||||
Name: person.Job.Company,
|
||||
Contexts: toBoolMapS(jscontact.OrganizationContextWork),
|
||||
}
|
||||
titleMaps[titleId] = map[string]any{
|
||||
"@type": "Title",
|
||||
"kind": "title",
|
||||
"name": person.Job.Title,
|
||||
"organizationId": orgId,
|
||||
}
|
||||
titleObjs[titleId] = jscontact.Title{
|
||||
Type: jscontact.TitleType,
|
||||
Kind: jscontact.TitleKindTitle,
|
||||
Name: person.Job.Title,
|
||||
OrganizationId: orgId,
|
||||
}
|
||||
}
|
||||
contact["organizations"] = organizationMaps
|
||||
contact["titles"] = titleMaps
|
||||
card.Organizations = organizationObjs
|
||||
card.Titles = titleObjs
|
||||
}
|
||||
|
||||
if err := propmap(i%2 == 0, 1, 1, contact, "cryptoKeys", &card.CryptoKeys, func(i int, id string) (map[string]any, jscontact.CryptoKey, error) {
|
||||
boxes.cryptoKey = true
|
||||
entity, err := openpgp.NewEntity(person.FirstName+" "+person.LastName, "test", person.Contact.Email, nil)
|
||||
if err != nil {
|
||||
return nil, jscontact.CryptoKey{}, err
|
||||
}
|
||||
var b bytes.Buffer
|
||||
err = entity.PrimaryKey.Serialize(&b)
|
||||
if err != nil {
|
||||
return nil, jscontact.CryptoKey{}, err
|
||||
}
|
||||
encoded := base64.RawStdEncoding.EncodeToString(b.Bytes())
|
||||
return map[string]any{
|
||||
"@type": "CryptoKey",
|
||||
"uri": "data:application/pgp-keys;base64," + encoded,
|
||||
"mediaType": "application/pgp-keys",
|
||||
}, jscontact.CryptoKey{
|
||||
Type: jscontact.CryptoKeyType,
|
||||
Uri: "data:application/pgp-keys;base64," + encoded,
|
||||
MediaType: "application/pgp-keys",
|
||||
}, nil
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
|
||||
if err := propmap(i%2 == 0, 1, 2, contact, "media", &card.Media, func(i int, id string) (map[string]any, jscontact.Media, error) {
|
||||
label := fmt.Sprintf("photo-%d", 1000+rand.Intn(9000))
|
||||
|
||||
r := 0
|
||||
if EnableMediaWithBlobId {
|
||||
r = rand.Intn(3)
|
||||
} else {
|
||||
r = rand.Intn(2)
|
||||
}
|
||||
|
||||
switch r {
|
||||
case 0:
|
||||
boxes.mediaWithDataUri = true
|
||||
// use data uri
|
||||
//size := 16 + rand.Intn(512-16+1) // <- let's not do that right now, makes debugging errors very difficult due to the ASCII wall noise
|
||||
size := pickRandom(16, 24, 32, 48, 64)
|
||||
img := gofakeit.ImagePng(size, size)
|
||||
mime := "image/png"
|
||||
uri := "data:" + mime + ";base64," + base64.StdEncoding.EncodeToString(img)
|
||||
contexts := toBoolMapS(jscontact.MediaContextPrivate)
|
||||
return map[string]any{
|
||||
"@type": "Media",
|
||||
"kind": string(jscontact.MediaKindPhoto),
|
||||
"uri": uri,
|
||||
"mediaType": mime,
|
||||
"contexts": structs.MapKeys(contexts, func(c jscontact.MediaContext) string { return string(c) }),
|
||||
"label": label,
|
||||
}, jscontact.Media{
|
||||
Type: jscontact.MediaType,
|
||||
Kind: jscontact.MediaKindPhoto,
|
||||
Uri: uri,
|
||||
MediaType: mime,
|
||||
Contexts: contexts,
|
||||
Label: label,
|
||||
}, nil
|
||||
|
||||
case 1:
|
||||
boxes.mediaWithExternalUri = true
|
||||
// use external uri
|
||||
uri := externalImageUri()
|
||||
contexts := toBoolMapS(jscontact.MediaContextWork)
|
||||
return map[string]any{
|
||||
"@type": "Media",
|
||||
"kind": string(jscontact.MediaKindPhoto),
|
||||
"uri": uri,
|
||||
"contexts": structs.MapKeys(contexts, func(c jscontact.MediaContext) string { return string(c) }),
|
||||
"label": label,
|
||||
}, jscontact.Media{
|
||||
Type: jscontact.MediaType,
|
||||
Kind: jscontact.MediaKindPhoto,
|
||||
Uri: uri,
|
||||
Contexts: contexts,
|
||||
Label: label,
|
||||
}, nil
|
||||
|
||||
default:
|
||||
boxes.mediaWithBlobId = true
|
||||
size := pickRandom(16, 24, 32, 48, 64)
|
||||
img := gofakeit.ImageJpeg(size, size)
|
||||
blob, err := c.uploadBlob(accountId, img, "image/jpeg")
|
||||
if err != nil {
|
||||
return nil, jscontact.Media{}, err
|
||||
}
|
||||
contexts := toBoolMapS(jscontact.MediaContextPrivate)
|
||||
return map[string]any{
|
||||
"@type": "Media",
|
||||
"kind": string(jscontact.MediaKindPhoto),
|
||||
"blobId": blob.BlobId,
|
||||
"contexts": structs.MapKeys(contexts, func(c jscontact.MediaContext) string { return string(c) }),
|
||||
"label": label,
|
||||
}, jscontact.Media{
|
||||
Type: jscontact.MediaType,
|
||||
Kind: jscontact.MediaKindPhoto,
|
||||
BlobId: blob.BlobId,
|
||||
MediaType: blob.Type,
|
||||
Contexts: contexts,
|
||||
Label: label,
|
||||
}, nil
|
||||
|
||||
}
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
if err := propmap(i%2 == 0, 1, 1, contact, "links", &card.Links, func(i int, id string) (map[string]any, jscontact.Link, error) {
|
||||
boxes.link = true
|
||||
return map[string]any{
|
||||
"@type": "Link",
|
||||
"kind": "contact",
|
||||
"uri": "mailto:" + person.Contact.Email,
|
||||
"pref": (i + 1) * 10,
|
||||
}, jscontact.Link{
|
||||
Type: jscontact.LinkType,
|
||||
Kind: jscontact.LinkKindContact,
|
||||
Uri: "mailto:" + person.Contact.Email,
|
||||
Pref: uint((i + 1) * 10),
|
||||
}, nil
|
||||
}); err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
|
||||
id, err := s.CreateContact(c, accountId, contact)
|
||||
if err != nil {
|
||||
return "", "", nil, boxes, err
|
||||
}
|
||||
card.Id = id
|
||||
filled[id] = card
|
||||
printer(fmt.Sprintf("🧑🏻 created %*s/%v id=%v", int(math.Log10(float64(count))+1), strconv.Itoa(int(i+1)), count, id))
|
||||
}
|
||||
return accountId, addressbookId, filled, boxes, nil
|
||||
}
|
||||
|
||||
func (s *StalwartTest) CreateContact(j *TestJmapClient, accountId string, contact map[string]any) (string, error) {
|
||||
return j.create1(accountId, ContactCardType, JmapContacts, contact)
|
||||
}
|
||||
748
pkg/jmap/jmap_integration_email_test.go
Normal file
748
pkg/jmap/jmap_integration_email_test.go
Normal file
@@ -0,0 +1,748 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"math/rand"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/mail"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v7"
|
||||
"github.com/emersion/go-imap/v2"
|
||||
"github.com/emersion/go-imap/v2/imapclient"
|
||||
"github.com/jhillyerd/enmime/v2"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEmails(t *testing.T) {
|
||||
if skip(t) {
|
||||
return
|
||||
}
|
||||
|
||||
count := 15 + rand.Intn(20)
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
s, err := newStalwartTest(t)
|
||||
require.NoError(err)
|
||||
defer s.Close()
|
||||
|
||||
user := pickUser()
|
||||
session := s.Session(user.name)
|
||||
|
||||
accountId := session.PrimaryAccounts.Mail
|
||||
|
||||
inboxId, inboxFolder := s.findInbox(t, accountId, session)
|
||||
|
||||
var threads int = 0
|
||||
var mails []filledMail = nil
|
||||
{
|
||||
mails, threads, err = s.fillEmailsWithImap(inboxFolder, count, false, user)
|
||||
require.NoError(err)
|
||||
}
|
||||
mailsByMessageId := structs.Index(mails, func(mail filledMail) string { return mail.messageId })
|
||||
|
||||
{
|
||||
{
|
||||
resp, sessionState, _, _, err := s.client.GetAllIdentities(accountId, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.Len(resp, 1)
|
||||
require.Equal(user.email, resp[0].Email)
|
||||
require.Equal(user.description, resp[0].Name)
|
||||
}
|
||||
|
||||
{
|
||||
respByAccountId, sessionState, _, _, err := s.client.GetAllMailboxes([]string{accountId}, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.Len(respByAccountId, 1)
|
||||
require.Contains(respByAccountId, accountId)
|
||||
resp := respByAccountId[accountId]
|
||||
mailboxesUnreadByRole := map[string]int{}
|
||||
for _, m := range resp {
|
||||
if m.Role != "" {
|
||||
mailboxesUnreadByRole[m.Role] = m.UnreadEmails
|
||||
}
|
||||
}
|
||||
require.LessOrEqual(mailboxesUnreadByRole["inbox"], count)
|
||||
}
|
||||
|
||||
{
|
||||
resp, sessionState, _, _, err := s.client.GetAllEmailsInMailbox(accountId, session, s.ctx, s.logger, "", inboxId, 0, 0, true, false, 0, true)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
|
||||
require.Equalf(threads, len(resp.Emails), "the number of collapsed emails in the inbox is expected to be %v, but is actually %v", threads, len(resp.Emails))
|
||||
for _, e := range resp.Emails {
|
||||
require.Len(e.MessageId, 1)
|
||||
expectation, ok := mailsByMessageId[e.MessageId[0]]
|
||||
require.True(ok)
|
||||
matchEmail(t, e, expectation, false)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
resp, sessionState, _, _, err := s.client.GetAllEmailsInMailbox(accountId, session, s.ctx, s.logger, "", inboxId, 0, 0, false, false, 0, true)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
|
||||
require.Equalf(count, len(resp.Emails), "the number of emails in the inbox is expected to be %v, but is actually %v", count, len(resp.Emails))
|
||||
for _, e := range resp.Emails {
|
||||
require.Len(e.MessageId, 1)
|
||||
expectation, ok := mailsByMessageId[e.MessageId[0]]
|
||||
require.True(ok)
|
||||
matchEmail(t, e, expectation, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendingEmails(t *testing.T) {
|
||||
if skip(t) {
|
||||
return
|
||||
}
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
s, err := newStalwartTest(t)
|
||||
require.NoError(err)
|
||||
defer s.Close()
|
||||
|
||||
from := pickUser()
|
||||
session := s.Session(from.name)
|
||||
accountId := session.PrimaryAccounts.Mail
|
||||
|
||||
var to User
|
||||
{
|
||||
others := structs.Filter(users[:], func(u User) bool { return u.name != from.name })
|
||||
to = others[rand.Intn(len(others))]
|
||||
}
|
||||
toSession := s.Session(to.name)
|
||||
toAccountId := toSession.PrimaryAccounts.Mail
|
||||
|
||||
var cc User
|
||||
{
|
||||
others := structs.Filter(users[:], func(u User) bool { return u.name != from.name && u.name != to.name })
|
||||
cc = others[rand.Intn(len(others))]
|
||||
}
|
||||
ccSession := s.Session(cc.name)
|
||||
ccAccountId := ccSession.PrimaryAccounts.Mail
|
||||
|
||||
var mailboxPerRole map[string]Mailbox
|
||||
{
|
||||
mailboxes, _, _, _, err := s.client.GetAllMailboxes([]string{accountId}, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
mailboxPerRole = structs.Index(mailboxes[accountId], func(m Mailbox) string { return m.Role })
|
||||
require.Contains(mailboxPerRole, JmapMailboxRoleInbox)
|
||||
require.Contains(mailboxPerRole, JmapMailboxRoleDrafts)
|
||||
require.Contains(mailboxPerRole, JmapMailboxRoleSent)
|
||||
require.Contains(mailboxPerRole, JmapMailboxRoleTrash)
|
||||
}
|
||||
{
|
||||
roles := []string{JmapMailboxRoleDrafts, JmapMailboxRoleSent, JmapMailboxRoleInbox}
|
||||
m, _, _, _, err := s.client.SearchMailboxIdsPerRole([]string{accountId}, session, s.ctx, s.logger, "", roles)
|
||||
require.NoError(err)
|
||||
require.Contains(m, accountId)
|
||||
a := m[accountId]
|
||||
for _, role := range roles {
|
||||
require.Contains(a, role)
|
||||
}
|
||||
}
|
||||
|
||||
// let's ensure that the recipients have zero emails in their mailboxes before we send them any
|
||||
for _, u := range []struct {
|
||||
accountId string
|
||||
session *Session
|
||||
}{{toAccountId, toSession}, {ccAccountId, ccSession}} {
|
||||
mailboxes, _, _, _, err := s.client.GetAllMailboxes([]string{u.accountId}, u.session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
for _, mailbox := range mailboxes[u.accountId] {
|
||||
require.Equal(0, mailbox.TotalEmails)
|
||||
}
|
||||
}
|
||||
|
||||
subject := fmt.Sprintf("Test Subject %d", 10000+rand.Intn(90000))
|
||||
fromName := fmt.Sprintf("%s (test %d)", from.name, 1000+rand.Intn(9000))
|
||||
sender := EmailAddress{Email: from.email, Name: from.description}
|
||||
|
||||
{
|
||||
var identity Identity
|
||||
{
|
||||
identities, _, _, _, err := s.client.GetAllIdentities(accountId, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.NotEmpty(identities)
|
||||
identity = identities[0]
|
||||
}
|
||||
|
||||
create := EmailCreate{
|
||||
Keywords: toBoolMapS("test"),
|
||||
Subject: subject,
|
||||
MailboxIds: toBoolMapS(mailboxPerRole[JmapMailboxRoleDrafts].Id),
|
||||
}
|
||||
created, _, _, _, err := s.client.CreateEmail(accountId, create, "", session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.NotEmpty(created.Id)
|
||||
|
||||
{
|
||||
emails, notFound, _, _, _, err := s.client.GetEmails(accountId, session, s.ctx, s.logger, "", []string{created.Id}, true, 0, false, false)
|
||||
require.NoError(err)
|
||||
require.Len(emails, 1)
|
||||
require.Empty(notFound)
|
||||
email := emails[0]
|
||||
require.Equal(created.Id, email.Id)
|
||||
require.Len(email.MailboxIds, 1)
|
||||
require.Contains(email.MailboxIds, mailboxPerRole[JmapMailboxRoleDrafts].Id)
|
||||
}
|
||||
|
||||
update := EmailCreate{
|
||||
From: []EmailAddress{{Name: fromName, Email: from.email}},
|
||||
To: []EmailAddress{{Name: to.description, Email: to.email}},
|
||||
Cc: []EmailAddress{{Name: cc.description, Email: cc.email}},
|
||||
Sender: []EmailAddress{sender},
|
||||
Keywords: toBoolMapS("test"),
|
||||
Subject: subject,
|
||||
MailboxIds: toBoolMapS(mailboxPerRole[JmapMailboxRoleDrafts].Id),
|
||||
}
|
||||
updated, _, _, _, err := s.client.CreateEmail(accountId, update, created.Id, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.NotEmpty(updated.Id)
|
||||
require.NotEqual(created.Id, updated.Id)
|
||||
|
||||
var updatedMailboxId string
|
||||
{
|
||||
emails, notFound, _, _, _, err := s.client.GetEmails(accountId, session, s.ctx, s.logger, "", []string{created.Id, updated.Id}, true, 0, false, false)
|
||||
require.NoError(err)
|
||||
require.Len(emails, 1)
|
||||
require.Len(notFound, 1)
|
||||
email := emails[0]
|
||||
require.Equal(updated.Id, email.Id)
|
||||
require.Len(email.MailboxIds, 1)
|
||||
require.Contains(email.MailboxIds, mailboxPerRole[JmapMailboxRoleDrafts].Id)
|
||||
require.Equal(notFound[0], created.Id)
|
||||
var ok bool
|
||||
updatedMailboxId, ok = structs.FirstKey(email.MailboxIds)
|
||||
require.True(ok)
|
||||
}
|
||||
|
||||
move := MoveMail{
|
||||
FromMailboxId: updatedMailboxId,
|
||||
ToMailboxId: mailboxPerRole[JmapMailboxRoleSent].Id,
|
||||
}
|
||||
|
||||
sub, _, _, _, err := s.client.SubmitEmail(accountId, identity.Id, updated.Id, &move, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.NotEmpty(sub.Id)
|
||||
require.NotEmpty(sub.ThreadId)
|
||||
require.Equal(updated.Id, sub.EmailId)
|
||||
require.Equal(identity.Id, sub.IdentityId)
|
||||
require.Equal(sub.UndoStatus, UndoStatusPending) // this *might* be fragile: if the server is fast enough, would we get "final" here?
|
||||
require.Empty(sub.DsnBlobIds)
|
||||
require.Empty(sub.MdnBlobIds)
|
||||
require.Equal(from.email, sub.Envelope.MailFrom.Email)
|
||||
require.Nil(sub.Envelope.MailFrom.Parameters)
|
||||
require.Len(sub.Envelope.RcptTo, 2)
|
||||
require.Contains(sub.Envelope.RcptTo, Address{Email: to.email})
|
||||
require.Contains(sub.Envelope.RcptTo, Address{Email: cc.email})
|
||||
require.NotZero(sub.SendAt)
|
||||
require.Len(sub.DeliveryStatus, 2)
|
||||
require.Contains(sub.DeliveryStatus, to.email)
|
||||
require.Contains(sub.DeliveryStatus, cc.email)
|
||||
|
||||
a := 0
|
||||
maxAttempts := 3
|
||||
delivery := sub.DeliveryStatus[to.email].Delivered
|
||||
|
||||
for delivery != DeliveredYes {
|
||||
require.NotEqual(DeliveredNo, delivery)
|
||||
a++
|
||||
if a >= maxAttempts {
|
||||
break
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
subs, notFound, _, _, _, err := s.client.GetEmailSubmissionStatus(accountId, []string{sub.Id}, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.Empty(notFound)
|
||||
require.Contains(subs, sub.Id)
|
||||
delivery = subs[sub.Id].DeliveryStatus[to.email].Delivered
|
||||
}
|
||||
|
||||
require.Contains([]DeliveryStatusDelivered{DeliveredYes, DeliveredUnknown}, delivery)
|
||||
|
||||
for _, r := range []struct {
|
||||
user User
|
||||
accountId string
|
||||
session *Session
|
||||
}{{to, toAccountId, toSession}, {cc, ccAccountId, ccSession}} {
|
||||
mailboxes, _, _, _, err := s.client.GetAllMailboxes([]string{r.accountId}, r.session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
inboxId := ""
|
||||
for _, mailbox := range mailboxes[r.accountId] {
|
||||
if mailbox.Role == JmapMailboxRoleInbox {
|
||||
inboxId = mailbox.Id
|
||||
require.Equal(1, mailbox.TotalEmails)
|
||||
}
|
||||
}
|
||||
require.NotEmpty(inboxId, "failed to find the Mailbox with the 'inbox' role for %v", r.user.name)
|
||||
|
||||
emails, _, _, _, err := s.client.QueryEmails([]string{r.accountId}, EmailFilterCondition{InMailbox: inboxId}, r.session, s.ctx, s.logger, "", 0, 0, true, 0)
|
||||
require.NoError(err)
|
||||
require.Contains(emails, r.accountId)
|
||||
require.Len(emails[r.accountId].Emails, 1)
|
||||
received := emails[r.accountId].Emails[0]
|
||||
require.Len(received.From, 1)
|
||||
require.Equal(from.email, received.From[0].Email)
|
||||
require.Equal(fromName, received.From[0].Name)
|
||||
require.Len(received.Sender, 1)
|
||||
require.Equal(from.email, received.Sender[0].Email)
|
||||
require.Equal(from.description, received.Sender[0].Name)
|
||||
require.Len(received.To, 1)
|
||||
require.Equal(to.email, received.To[0].Email)
|
||||
require.Equal(to.description, received.To[0].Name)
|
||||
require.Len(received.Cc, 1)
|
||||
require.Equal(cc.email, received.Cc[0].Email)
|
||||
require.Equal(cc.description, received.Cc[0].Name)
|
||||
require.Equal(subject, received.Subject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func matchEmail(t *testing.T, actual Email, expected filledMail, hasBodies bool) {
|
||||
require := require.New(t)
|
||||
require.Len(actual.MessageId, 1)
|
||||
require.Equal(expected.messageId, actual.MessageId[0])
|
||||
require.Equal(expected.subject, actual.Subject)
|
||||
require.NotEmpty(actual.Preview)
|
||||
if hasBodies {
|
||||
require.Len(actual.TextBody, 1)
|
||||
textBody := actual.TextBody[0]
|
||||
partId := textBody.PartId
|
||||
require.Contains(actual.BodyValues, partId)
|
||||
content := actual.BodyValues[partId].Value
|
||||
require.True(strings.Contains(content, actual.Preview), "text body contains preview")
|
||||
} else {
|
||||
require.Empty(actual.BodyValues)
|
||||
}
|
||||
require.ElementsMatch(slices.Collect(maps.Keys(actual.Keywords)), expected.keywords)
|
||||
|
||||
{
|
||||
list := make([]filledAttachment, len(actual.Attachments))
|
||||
for i, a := range actual.Attachments {
|
||||
list[i] = filledAttachment{
|
||||
name: a.Name,
|
||||
size: a.Size,
|
||||
mimeType: a.Type,
|
||||
disposition: a.Disposition,
|
||||
}
|
||||
require.NotEmpty(a.BlobId)
|
||||
require.NotEmpty(a.PartId)
|
||||
}
|
||||
|
||||
require.ElementsMatch(list, expected.attachments)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StalwartTest) findInbox(t *testing.T, accountId string, session *Session) (string, string) {
|
||||
require := require.New(t)
|
||||
respByAccountId, sessionState, _, _, err := s.client.GetAllMailboxes([]string{accountId}, session, s.ctx, s.logger, "")
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.Len(respByAccountId, 1)
|
||||
require.Contains(respByAccountId, accountId)
|
||||
resp := respByAccountId[accountId]
|
||||
|
||||
mailboxesNameByRole := map[string]string{}
|
||||
mailboxesUnreadByRole := map[string]int{}
|
||||
for _, m := range resp {
|
||||
if m.Role != "" {
|
||||
mailboxesNameByRole[m.Role] = m.Name
|
||||
mailboxesUnreadByRole[m.Role] = m.UnreadEmails
|
||||
}
|
||||
}
|
||||
require.Contains(mailboxesNameByRole, "inbox")
|
||||
require.Contains(mailboxesUnreadByRole, "inbox")
|
||||
require.Zero(mailboxesUnreadByRole["inbox"])
|
||||
|
||||
inboxId := mailboxId("inbox", resp)
|
||||
require.NotEmpty(inboxId)
|
||||
inboxFolder := mailboxesNameByRole["inbox"]
|
||||
require.NotEmpty(inboxFolder)
|
||||
return inboxId, inboxFolder
|
||||
}
|
||||
|
||||
var emailSplitter = regexp.MustCompile("(.+)@(.+)$")
|
||||
|
||||
func htmlFormat(body string, msg enmime.MailBuilder) enmime.MailBuilder {
|
||||
return msg.HTML([]byte(toHtml(body)))
|
||||
}
|
||||
|
||||
func textFormat(body string, msg enmime.MailBuilder) enmime.MailBuilder {
|
||||
return msg.Text([]byte(body))
|
||||
}
|
||||
|
||||
func bothFormat(body string, msg enmime.MailBuilder) enmime.MailBuilder {
|
||||
msg = htmlFormat(body, msg)
|
||||
msg = textFormat(body, msg)
|
||||
return msg
|
||||
}
|
||||
|
||||
var formats = []func(string, enmime.MailBuilder) enmime.MailBuilder{
|
||||
htmlFormat,
|
||||
textFormat,
|
||||
bothFormat,
|
||||
}
|
||||
|
||||
type sender struct {
|
||||
first string
|
||||
last string
|
||||
from string
|
||||
sender string
|
||||
}
|
||||
|
||||
func (s sender) inject(b enmime.MailBuilder) enmime.MailBuilder {
|
||||
return b.From(s.first+" "+s.last, s.from).Header("Sender", s.sender)
|
||||
}
|
||||
|
||||
type senderGenerator struct {
|
||||
senders []sender
|
||||
}
|
||||
|
||||
func newSenderGenerator(numSenders int) senderGenerator {
|
||||
senders := make([]sender, numSenders)
|
||||
for i := range numSenders {
|
||||
person := gofakeit.Person()
|
||||
senders[i] = sender{
|
||||
first: person.FirstName,
|
||||
last: person.LastName,
|
||||
from: person.Contact.Email,
|
||||
sender: person.FirstName + " " + person.LastName + "<" + person.Contact.Email + ">",
|
||||
}
|
||||
}
|
||||
return senderGenerator{
|
||||
senders: senders,
|
||||
}
|
||||
}
|
||||
|
||||
func (s senderGenerator) nextSender() *sender {
|
||||
if len(s.senders) < 1 {
|
||||
panic("failed to determine a sender to use")
|
||||
} else {
|
||||
return &s.senders[rand.Intn(len(s.senders))]
|
||||
}
|
||||
}
|
||||
|
||||
func fakeFilename(extension string) string {
|
||||
return strings.ReplaceAll(gofakeit.Product().Name, " ", "_") + extension
|
||||
}
|
||||
|
||||
func mailboxId(role string, mailboxes []Mailbox) string {
|
||||
for _, m := range mailboxes {
|
||||
if m.Role == role {
|
||||
return m.Id
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type filledAttachment struct {
|
||||
name string
|
||||
size int
|
||||
mimeType string
|
||||
disposition string
|
||||
}
|
||||
|
||||
type filledMail struct {
|
||||
uid int
|
||||
attachments []filledAttachment
|
||||
subject string
|
||||
testId string
|
||||
messageId string
|
||||
keywords []string
|
||||
}
|
||||
|
||||
var allKeywords = map[string]imap.Flag{
|
||||
JmapKeywordAnswered: imap.FlagAnswered,
|
||||
JmapKeywordDraft: imap.FlagDraft,
|
||||
JmapKeywordFlagged: imap.FlagFlagged,
|
||||
JmapKeywordForwarded: imap.FlagForwarded,
|
||||
JmapKeywordJunk: imap.FlagJunk,
|
||||
JmapKeywordMdnSent: imap.FlagMDNSent,
|
||||
JmapKeywordNotJunk: imap.FlagNotJunk,
|
||||
JmapKeywordPhishing: imap.FlagPhishing,
|
||||
JmapKeywordSeen: imap.FlagSeen,
|
||||
}
|
||||
|
||||
func (s *StalwartTest) fillEmailsWithImap(folder string, count int, empty bool, user User) ([]filledMail, int, error) {
|
||||
to := fmt.Sprintf("%s <%s>", user.description, user.email)
|
||||
ccEvery := 2
|
||||
bccEvery := 3
|
||||
attachmentEvery := 2
|
||||
senders := max(count/4, 1)
|
||||
maxThreadSize := 6
|
||||
maxAttachments := 4
|
||||
|
||||
tlsConfig := &tls.Config{InsecureSkipVerify: true}
|
||||
|
||||
c, err := imapclient.DialTLS(net.JoinHostPort(s.ip, strconv.Itoa(s.imapPort)), &imapclient.Options{TLSConfig: tlsConfig})
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
defer func(imap *imapclient.Client) {
|
||||
err := imap.Close()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}(c)
|
||||
|
||||
if err = c.Login(user.name, user.password).Wait(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if _, err = c.Select(folder, &imap.SelectOptions{ReadOnly: false}).Wait(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if empty {
|
||||
if ids, err := c.Search(&imap.SearchCriteria{}, nil).Wait(); err != nil {
|
||||
return nil, 0, err
|
||||
} else {
|
||||
if len(ids.AllSeqNums()) > 0 {
|
||||
storeFlags := imap.StoreFlags{
|
||||
Op: imap.StoreFlagsAdd,
|
||||
Flags: []imap.Flag{imap.FlagDeleted},
|
||||
Silent: true,
|
||||
}
|
||||
if err = c.Store(ids.All, &storeFlags, nil).Close(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err = c.Expunge().Close(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
log.Printf("🗑️ deleted %d messages in %s", len(ids.AllSeqNums()), folder)
|
||||
} else {
|
||||
log.Printf("ℹ️ did not delete any messages, %s is empty", folder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
address, err := mail.ParseAddress(to)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
displayName := address.Name
|
||||
|
||||
addressParts := emailSplitter.FindAllStringSubmatch(address.Address, 3)
|
||||
if len(addressParts) != 1 {
|
||||
return nil, 0, fmt.Errorf("address does not have one part: '%v' -> %v", address.Address, addressParts)
|
||||
}
|
||||
if len(addressParts[0]) != 3 {
|
||||
return nil, 0, fmt.Errorf("first address part does not have a size of 3: '%v'", addressParts[0])
|
||||
}
|
||||
|
||||
domain := addressParts[0][2]
|
||||
|
||||
toName := displayName
|
||||
toAddress := fmt.Sprintf("%s@%s", user.name, domain)
|
||||
ccName1 := "Team Lead"
|
||||
ccAddress1 := fmt.Sprintf("lead@%s", domain)
|
||||
ccName2 := "Coworker"
|
||||
ccAddress2 := fmt.Sprintf("coworker@%s", domain)
|
||||
bccName := "HR"
|
||||
bccAddress := fmt.Sprintf("corporate@%s", domain)
|
||||
|
||||
sg := newSenderGenerator(senders)
|
||||
thread := 0
|
||||
mails := make([]filledMail, count)
|
||||
for i := 0; i < count; thread++ {
|
||||
threadMessageId := fmt.Sprintf("%d.%d@%s", time.Now().Unix(), 1000000+rand.Intn(8999999), domain)
|
||||
threadSubject := strings.Trim(gofakeit.SentenceSimple(), ".") // remove the . at the end, looks weird
|
||||
threadSize := 1 + rand.Intn(maxThreadSize)
|
||||
lastMessageId := ""
|
||||
lastSubject := ""
|
||||
for t := 0; i < count && t < threadSize; t++ {
|
||||
sender := sg.nextSender()
|
||||
|
||||
format := formats[i%len(formats)]
|
||||
text := gofakeit.Paragraph(2+rand.Intn(9), 1+rand.Intn(4), 1+rand.Intn(32), "\n")
|
||||
|
||||
msg := sender.inject(enmime.Builder().To(toName, toAddress))
|
||||
|
||||
messageId := ""
|
||||
if lastMessageId == "" {
|
||||
// start a new thread
|
||||
msg = msg.Header("Message-ID", threadMessageId).Subject(threadSubject)
|
||||
lastMessageId = threadMessageId
|
||||
lastSubject = threadSubject
|
||||
messageId = threadMessageId
|
||||
} else {
|
||||
// we're continuing a thread
|
||||
messageId = fmt.Sprintf("%d.%d@%s", time.Now().Unix(), 1000000+rand.Intn(8999999), domain)
|
||||
inReplyTo := ""
|
||||
subject := ""
|
||||
switch rand.Intn(2) {
|
||||
case 0:
|
||||
// reply to first post in thread
|
||||
subject = "Re: " + threadSubject
|
||||
inReplyTo = threadMessageId
|
||||
default:
|
||||
// reply to last addition to thread
|
||||
subject = "Re: " + lastSubject
|
||||
inReplyTo = lastMessageId
|
||||
}
|
||||
msg = msg.Header("Message-ID", messageId).Header("In-Reply-To", inReplyTo).Subject(subject)
|
||||
lastMessageId = messageId
|
||||
lastSubject = subject
|
||||
}
|
||||
|
||||
if i%ccEvery == 0 {
|
||||
msg = msg.CCAddrs([]mail.Address{{Name: ccName1, Address: ccAddress1}, {Name: ccName2, Address: ccAddress2}})
|
||||
}
|
||||
if i%bccEvery == 0 {
|
||||
msg = msg.BCC(bccName, bccAddress)
|
||||
}
|
||||
|
||||
numAttachments := 0
|
||||
attachments := []filledAttachment{}
|
||||
if maxAttachments > 0 && i%attachmentEvery == 0 {
|
||||
numAttachments = rand.Intn(maxAttachments)
|
||||
for a := range numAttachments {
|
||||
switch rand.Intn(2) {
|
||||
case 0:
|
||||
filename := fakeFilename(".txt")
|
||||
attachment := gofakeit.Paragraph(2+rand.Intn(4), 1+rand.Intn(4), 1+rand.Intn(32), "\n")
|
||||
data := []byte(attachment)
|
||||
msg = msg.AddAttachment(data, "text/plain", filename)
|
||||
attachments = append(attachments, filledAttachment{
|
||||
name: filename,
|
||||
size: len(data),
|
||||
mimeType: "text/plain",
|
||||
disposition: "attachment",
|
||||
})
|
||||
default:
|
||||
filename := ""
|
||||
mimetype := ""
|
||||
var image []byte = nil
|
||||
switch rand.Intn(2) {
|
||||
case 0:
|
||||
filename = fakeFilename(".png")
|
||||
mimetype = "image/png"
|
||||
image = gofakeit.ImagePng(512, 512)
|
||||
default:
|
||||
filename = fakeFilename(".jpg")
|
||||
mimetype = "image/jpeg"
|
||||
image = gofakeit.ImageJpeg(400, 200)
|
||||
}
|
||||
disposition := ""
|
||||
switch rand.Intn(2) {
|
||||
case 0:
|
||||
msg = msg.AddAttachment(image, mimetype, filename)
|
||||
disposition = "attachment"
|
||||
default:
|
||||
msg = msg.AddInline(image, mimetype, filename, "c"+strconv.Itoa(a))
|
||||
disposition = "inline"
|
||||
}
|
||||
attachments = append(attachments, filledAttachment{
|
||||
name: filename,
|
||||
size: len(image),
|
||||
mimeType: mimetype,
|
||||
disposition: disposition,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = format(text, msg)
|
||||
|
||||
flags := []imap.Flag{}
|
||||
keywords := pickRandomlyFromMap(allKeywords, 0, len(allKeywords))
|
||||
for _, f := range keywords {
|
||||
flags = append(flags, f)
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
part, _ := msg.Build()
|
||||
part.Encode(buf)
|
||||
mail := buf.String()
|
||||
|
||||
var options *imap.AppendOptions = nil
|
||||
if len(flags) > 0 {
|
||||
options = &imap.AppendOptions{Flags: flags}
|
||||
}
|
||||
|
||||
size := int64(len(mail))
|
||||
appendCmd := c.Append(folder, size, options)
|
||||
if _, err := appendCmd.Write([]byte(mail)); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err := appendCmd.Close(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if appendData, err := appendCmd.Wait(); err != nil {
|
||||
return nil, 0, err
|
||||
} else {
|
||||
attachmentStr := ""
|
||||
if numAttachments > 0 {
|
||||
attachmentStr = " " + strings.Repeat("📎", numAttachments)
|
||||
}
|
||||
log.Printf("➕ appended %v/%v [in thread %v] uid=%v%s", i+1, count, thread+1, appendData.UID, attachmentStr)
|
||||
|
||||
mails[i] = filledMail{
|
||||
uid: int(appendData.UID),
|
||||
attachments: attachments,
|
||||
subject: msg.GetSubject(),
|
||||
messageId: messageId,
|
||||
keywords: slices.Collect(maps.Keys(keywords)),
|
||||
}
|
||||
}
|
||||
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
listCmd := c.List("", "%", &imap.ListOptions{
|
||||
ReturnStatus: &imap.StatusOptions{
|
||||
NumMessages: true,
|
||||
NumUnseen: true,
|
||||
},
|
||||
})
|
||||
countMap := map[string]int{}
|
||||
for {
|
||||
mbox := listCmd.Next()
|
||||
if mbox == nil {
|
||||
break
|
||||
}
|
||||
countMap[mbox.Mailbox] = int(*mbox.Status.NumMessages)
|
||||
}
|
||||
|
||||
inboxCount := -1
|
||||
for f, i := range countMap {
|
||||
if strings.Compare(strings.ToLower(f), strings.ToLower(folder)) == 0 {
|
||||
inboxCount = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if err = listCmd.Close(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if inboxCount == -1 {
|
||||
return nil, 0, fmt.Errorf("failed to find folder '%v' via IMAP", folder)
|
||||
}
|
||||
if empty && count != inboxCount {
|
||||
return nil, 0, fmt.Errorf("wrong number of emails in the inbox after filling, expecting %v, has %v", count, inboxCount)
|
||||
}
|
||||
|
||||
return mails, thread, nil
|
||||
}
|
||||
621
pkg/jmap/jmap_integration_event_test.go
Normal file
621
pkg/jmap/jmap_integration_event_test.go
Normal file
@@ -0,0 +1,621 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v7"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/jscalendar"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
// fields that are currently unsupported in Stalwart
|
||||
const (
|
||||
EnableEventMayInviteFields = false
|
||||
EnableEventParticipantDescriptionFields = false
|
||||
)
|
||||
|
||||
func TestEvents(t *testing.T) {
|
||||
if skip(t) {
|
||||
return
|
||||
}
|
||||
|
||||
count := uint(20 + rand.Intn(30))
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
s, err := newStalwartTest(t)
|
||||
require.NoError(err)
|
||||
defer s.Close()
|
||||
|
||||
user := pickUser()
|
||||
session := s.Session(user.name)
|
||||
|
||||
accountId, calendarId, expectedEventsById, boxes, err := s.fillEvents(t, count, session, user)
|
||||
require.NoError(err)
|
||||
require.NotEmpty(accountId)
|
||||
require.NotEmpty(calendarId)
|
||||
|
||||
filter := CalendarEventFilterCondition{
|
||||
InCalendar: calendarId,
|
||||
}
|
||||
sortBy := []CalendarEventComparator{
|
||||
{Property: CalendarEventPropertyStart, IsAscending: true},
|
||||
}
|
||||
|
||||
contactsByAccount, _, _, _, err := s.client.QueryCalendarEvents([]string{accountId}, session, t.Context(), s.logger, "", filter, sortBy, 0, 0)
|
||||
require.NoError(err)
|
||||
|
||||
require.Len(contactsByAccount, 1)
|
||||
require.Contains(contactsByAccount, accountId)
|
||||
contacts := contactsByAccount[accountId]
|
||||
require.Len(contacts, int(count))
|
||||
|
||||
for _, actual := range contacts {
|
||||
expected, ok := expectedEventsById[actual.Id]
|
||||
require.True(ok, "failed to find created contact by its id")
|
||||
matchEvent(t, actual, expected)
|
||||
}
|
||||
|
||||
exceptions := []string{}
|
||||
if !EnableEventMayInviteFields {
|
||||
exceptions = append(exceptions, "mayInvite")
|
||||
}
|
||||
allBoxesAreTicked(t, boxes, exceptions...)
|
||||
}
|
||||
|
||||
func matchEvent(t *testing.T, actual CalendarEvent, expected CalendarEvent) {
|
||||
//require.Equal(t, expected, actual)
|
||||
deepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
type EventsBoxes struct {
|
||||
categories bool
|
||||
keywords bool
|
||||
mayInvite bool
|
||||
}
|
||||
|
||||
func (s *StalwartTest) fillEvents(
|
||||
t *testing.T,
|
||||
count uint,
|
||||
session *Session,
|
||||
user User,
|
||||
) (string, string, map[string]CalendarEvent, EventsBoxes, error) {
|
||||
require := require.New(t)
|
||||
c, err := NewTestJmapClient(session, user.name, user.password, true, true)
|
||||
require.NoError(err)
|
||||
defer c.Close()
|
||||
|
||||
boxes := EventsBoxes{}
|
||||
|
||||
printer := func(s string) { log.Println(s) }
|
||||
|
||||
accountId := c.session.PrimaryAccounts.Calendars
|
||||
require.NotEmpty(accountId, "no primary account for calendars in session")
|
||||
|
||||
calendarId := ""
|
||||
{
|
||||
calendarsById, err := c.objectsById(accountId, CalendarType, JmapCalendars)
|
||||
require.NoError(err)
|
||||
|
||||
for id, calendar := range calendarsById {
|
||||
if isDefault, ok := calendar["isDefault"]; ok {
|
||||
if isDefault.(bool) {
|
||||
calendarId = id
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
require.NotEmpty(calendarId)
|
||||
|
||||
filled := map[string]CalendarEvent{}
|
||||
for i := range count {
|
||||
uid := gofakeit.UUID()
|
||||
|
||||
isDraft := false
|
||||
mainLocationId := ""
|
||||
locationIds := []string{}
|
||||
locationMaps := map[string]map[string]any{}
|
||||
locationObjs := map[string]jscalendar.Location{}
|
||||
{
|
||||
n := 1
|
||||
if i%4 == 0 {
|
||||
n++
|
||||
}
|
||||
for range n {
|
||||
locationId, locationMap, locationObj := pickLocation()
|
||||
locationMaps[locationId] = locationMap
|
||||
locationObjs[locationId] = locationObj
|
||||
locationIds = append(locationIds, locationId)
|
||||
if n > 0 && mainLocationId == "" {
|
||||
mainLocationId = locationId
|
||||
}
|
||||
}
|
||||
}
|
||||
virtualLocationId, virtualLocationMap, virtualLocationObj := pickVirtualLocation()
|
||||
participantMaps, participantObjs, organizerEmail := createParticipants(uid, locationIds, []string{virtualLocationId})
|
||||
duration := pickRandom("PT30M", "PT45M", "PT1H", "PT90M")
|
||||
tz := pickRandom(timezones...)
|
||||
daysDiff := rand.Intn(31) - 15
|
||||
t := time.Now().Add(time.Duration(daysDiff) * time.Hour * 24)
|
||||
h := pickRandom(9, 10, 11, 14, 15, 16, 18)
|
||||
m := pickRandom(0, 30)
|
||||
t = time.Date(t.Year(), t.Month(), t.Day(), h, m, 0, 0, t.Location())
|
||||
start := strings.ReplaceAll(t.Format(time.DateTime), " ", "T")
|
||||
title := gofakeit.Sentence(1)
|
||||
description := gofakeit.Paragraph(1+rand.Intn(3), 1+rand.Intn(4), 1+rand.Intn(32), "\n")
|
||||
|
||||
descriptionFormat := pickRandom("text/plain", "text/html")
|
||||
if descriptionFormat == "text/html" {
|
||||
description = toHtml(description)
|
||||
}
|
||||
status := pickRandom(jscalendar.Statuses...)
|
||||
freeBusy := pickRandom(jscalendar.FreeBusyStatuses...)
|
||||
privacy := pickRandom(jscalendar.Privacies...)
|
||||
color := pickRandom(basicColors...)
|
||||
locale := pickLocale()
|
||||
keywords := pickKeywords()
|
||||
categories := pickCategories()
|
||||
|
||||
sequence := 0
|
||||
|
||||
alertId := id()
|
||||
alertOffset := pickRandom("-PT5M", "-PT10M", "-PT15M")
|
||||
|
||||
event := map[string]any{
|
||||
"@type": "Event",
|
||||
"calendarIds": toBoolMapS(calendarId),
|
||||
"isDraft": isDraft,
|
||||
"start": start,
|
||||
"duration": duration,
|
||||
"status": string(status),
|
||||
"uid": uid,
|
||||
"prodId": productName,
|
||||
"title": title,
|
||||
"description": description,
|
||||
"descriptionContentType": descriptionFormat,
|
||||
"locale": locale,
|
||||
"color": color,
|
||||
"sequence": sequence,
|
||||
"showWithoutTime": false,
|
||||
"freeBusyStatus": string(freeBusy),
|
||||
"privacy": string(privacy),
|
||||
"sentBy": organizerEmail,
|
||||
"participants": participantMaps,
|
||||
"timeZone": tz,
|
||||
"hideAttendees": false,
|
||||
"replyTo": map[string]string{
|
||||
"imip": "mailto:" + organizerEmail,
|
||||
},
|
||||
"locations": locationMaps,
|
||||
"virtualLocations": map[string]any{
|
||||
virtualLocationId: virtualLocationMap,
|
||||
},
|
||||
"alerts": map[string]map[string]any{
|
||||
alertId: {
|
||||
"@type": "Alert",
|
||||
"trigger": map[string]any{
|
||||
"@type": "OffsetTrigger",
|
||||
"offset": alertOffset,
|
||||
"relativeTo": "start",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
obj := CalendarEvent{
|
||||
Id: "",
|
||||
CalendarIds: toBoolMapS(calendarId),
|
||||
IsDraft: isDraft,
|
||||
IsOrigin: true,
|
||||
Event: jscalendar.Event{
|
||||
Type: jscalendar.EventType,
|
||||
Start: jscalendar.LocalDateTime(start),
|
||||
Duration: jscalendar.Duration(duration),
|
||||
Status: status,
|
||||
Object: jscalendar.Object{
|
||||
CommonObject: jscalendar.CommonObject{
|
||||
Uid: uid,
|
||||
ProdId: productName,
|
||||
Title: title,
|
||||
Description: description,
|
||||
DescriptionContentType: descriptionFormat,
|
||||
Locale: locale,
|
||||
Color: color,
|
||||
},
|
||||
Sequence: uint(sequence),
|
||||
ShowWithoutTime: false,
|
||||
FreeBusyStatus: freeBusy,
|
||||
Privacy: privacy,
|
||||
SentBy: organizerEmail,
|
||||
Participants: participantObjs,
|
||||
TimeZone: tz,
|
||||
HideAttendees: false,
|
||||
ReplyTo: map[jscalendar.ReplyMethod]string{
|
||||
jscalendar.ReplyMethodImip: "mailto:" + organizerEmail,
|
||||
},
|
||||
Locations: locationObjs,
|
||||
VirtualLocations: map[string]jscalendar.VirtualLocation{
|
||||
virtualLocationId: virtualLocationObj,
|
||||
},
|
||||
Alerts: map[string]jscalendar.Alert{
|
||||
alertId: {
|
||||
Type: jscalendar.AlertType,
|
||||
Trigger: jscalendar.OffsetTrigger{
|
||||
Type: jscalendar.OffsetTriggerType,
|
||||
Offset: jscalendar.SignedDuration(alertOffset),
|
||||
RelativeTo: jscalendar.RelativeToStart,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if EnableEventMayInviteFields {
|
||||
event["mayInviteSelf"] = true
|
||||
event["mayInviteOthers"] = true
|
||||
obj.MayInviteSelf = true
|
||||
obj.MayInviteOthers = true
|
||||
boxes.mayInvite = true
|
||||
}
|
||||
|
||||
if len(keywords) > 0 {
|
||||
event["keywords"] = keywords
|
||||
obj.Keywords = keywords
|
||||
boxes.keywords = true
|
||||
}
|
||||
|
||||
if len(categories) > 0 {
|
||||
event["categories"] = categories
|
||||
obj.Categories = categories
|
||||
boxes.categories = true
|
||||
}
|
||||
|
||||
if mainLocationId != "" {
|
||||
event["mainLocationId"] = mainLocationId
|
||||
obj.MainLocationId = mainLocationId
|
||||
}
|
||||
|
||||
err = propmap(i%2 == 0, 1, 1, event, "links", &obj.Links, func(int, string) (map[string]any, jscalendar.Link, error) {
|
||||
mime := ""
|
||||
uri := ""
|
||||
rel := jscalendar.RelAbout
|
||||
switch rand.Intn(2) {
|
||||
case 0:
|
||||
size := pickRandom(16, 24, 32, 48, 64)
|
||||
img := gofakeit.ImagePng(size, size)
|
||||
mime = "image/png"
|
||||
uri = "data:" + mime + ";base64," + base64.StdEncoding.EncodeToString(img)
|
||||
default:
|
||||
mime = "image/jpeg"
|
||||
uri = externalImageUri()
|
||||
}
|
||||
return map[string]any{
|
||||
"@type": "Link",
|
||||
"href": uri,
|
||||
"contentType": mime,
|
||||
"rel": string(rel),
|
||||
}, jscalendar.Link{
|
||||
Type: jscalendar.LinkType,
|
||||
Href: uri,
|
||||
ContentType: mime,
|
||||
Rel: rel,
|
||||
}, nil
|
||||
})
|
||||
|
||||
if rand.Intn(10) > 7 {
|
||||
frequency := pickRandom(jscalendar.FrequencyWeekly, jscalendar.FrequencyDaily)
|
||||
interval := pickRandom(1, 2)
|
||||
count := 1
|
||||
if frequency == jscalendar.FrequencyWeekly {
|
||||
count = 1 + rand.Intn(8)
|
||||
} else {
|
||||
count = 1 + rand.Intn(4)
|
||||
}
|
||||
event["recurrenceRule"] = map[string]any{
|
||||
"@type": "RecurrenceRule",
|
||||
"frequency": string(frequency),
|
||||
"interval": interval,
|
||||
"rscale": string(jscalendar.RscaleIso8601),
|
||||
"skip": string(jscalendar.SkipOmit),
|
||||
"firstDayOfWeek": string(jscalendar.DayOfWeekMonday),
|
||||
"count": count,
|
||||
}
|
||||
rr := jscalendar.RecurrenceRule{
|
||||
Type: jscalendar.RecurrenceRuleType,
|
||||
Frequency: frequency,
|
||||
Interval: uint(interval),
|
||||
Rscale: jscalendar.RscaleIso8601,
|
||||
Skip: jscalendar.SkipOmit,
|
||||
FirstDayOfWeek: jscalendar.DayOfWeekMonday,
|
||||
Count: uint(count),
|
||||
}
|
||||
obj.RecurrenceRule = &rr
|
||||
}
|
||||
|
||||
id, err := s.CreateEvent(c, accountId, event)
|
||||
if err != nil {
|
||||
return accountId, calendarId, nil, boxes, err
|
||||
}
|
||||
|
||||
obj.Id = id
|
||||
filled[id] = obj
|
||||
|
||||
printer(fmt.Sprintf("📅 created %*s/%v id=%v", int(math.Log10(float64(count))+1), strconv.Itoa(int(i+1)), count, uid))
|
||||
}
|
||||
return accountId, calendarId, filled, boxes, nil
|
||||
}
|
||||
|
||||
func (s *StalwartTest) CreateEvent(j *TestJmapClient, accountId string, event map[string]any) (string, error) {
|
||||
return j.create1(accountId, CalendarEventType, JmapCalendars, event)
|
||||
}
|
||||
|
||||
var rooms = []jscalendar.Location{
|
||||
{
|
||||
Type: jscalendar.LocationType,
|
||||
Name: "Office meeting room upstairs",
|
||||
LocationTypes: toBoolMapS(jscalendar.LocationTypeOptionOffice),
|
||||
Coordinates: "geo:52.5335389,13.4103296",
|
||||
Links: map[string]jscalendar.Link{
|
||||
"l1": {Href: "https://www.heinlein-support.de/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: jscalendar.LocationType,
|
||||
Name: "office-nue",
|
||||
LocationTypes: toBoolMapS(jscalendar.LocationTypeOptionOffice),
|
||||
Coordinates: "geo:49.4723337,11.1042282",
|
||||
Links: map[string]jscalendar.Link{
|
||||
"l2": {Href: "https://www.workandpepper.de/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: jscalendar.LocationType,
|
||||
Name: "Meetingraum Prenzlauer Berg",
|
||||
LocationTypes: toBoolMapS(jscalendar.LocationTypeOptionOffice, jscalendar.LocationTypeOptionPublic),
|
||||
Coordinates: "geo:52.554222,13.4142387",
|
||||
Links: map[string]jscalendar.Link{
|
||||
"l3": {Href: "https://www.spacebase.com/en/venue/meeting-room-prenzlauer-be-11499/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: jscalendar.LocationType,
|
||||
Name: "Meetingraum LIANE 1",
|
||||
LocationTypes: toBoolMapS(jscalendar.LocationTypeOptionOffice, jscalendar.LocationTypeOptionLibrary),
|
||||
Coordinates: "geo:52.4854301,13.4224763",
|
||||
Links: map[string]jscalendar.Link{
|
||||
"l4": {Href: "https://www.spacebase.com/en/venue/rent-a-jungle-8372/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: jscalendar.LocationType,
|
||||
Name: "Dark Horse",
|
||||
LocationTypes: toBoolMapS(jscalendar.LocationTypeOptionOffice),
|
||||
Coordinates: "geo:52.4942254,13.4346015",
|
||||
Links: map[string]jscalendar.Link{
|
||||
"l5": {Href: "https://www.spacebase.com/en/event-venue/workshop-white-space-2667/"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var virtualRooms = []jscalendar.VirtualLocation{
|
||||
{
|
||||
Type: jscalendar.VirtualLocationType,
|
||||
Name: "opentalk",
|
||||
Uri: "https://meet.opentalk.eu/fake/room/06fb8f7d-42eb-4212-8112-769fac2cb111",
|
||||
Features: toBoolMapS(
|
||||
jscalendar.VirtualLocationFeatureAudio,
|
||||
jscalendar.VirtualLocationFeatureChat,
|
||||
jscalendar.VirtualLocationFeatureVideo,
|
||||
jscalendar.VirtualLocationFeatureScreen,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
func pickLocation() (string, map[string]any, jscalendar.Location) {
|
||||
locationId := id()
|
||||
room := rooms[rand.Intn(len(rooms))]
|
||||
b, err := json.Marshal(room)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var m map[string]any
|
||||
err = json.Unmarshal(b, &m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return locationId, m, room
|
||||
}
|
||||
|
||||
func pickVirtualLocation() (string, map[string]any, jscalendar.VirtualLocation) {
|
||||
locationId := id()
|
||||
vroom := virtualRooms[rand.Intn(len(virtualRooms))]
|
||||
b, err := json.Marshal(vroom)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var m map[string]any
|
||||
err = json.Unmarshal(b, &m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return locationId, m, vroom
|
||||
}
|
||||
|
||||
var ChairRoles = toBoolMapS(jscalendar.RoleChair, jscalendar.RoleOwner)
|
||||
var RegularRoles = toBoolMapS(jscalendar.RoleOptional)
|
||||
|
||||
func createParticipants(uid string, locationIds []string, virtualLocationIds []string) (map[string]map[string]any, map[string]jscalendar.Participant, string) {
|
||||
options := structs.Concat(locationIds, virtualLocationIds)
|
||||
n := 1 + rand.Intn(4)
|
||||
maps := map[string]map[string]any{}
|
||||
objs := map[string]jscalendar.Participant{}
|
||||
organizerId, organizerEmail, organizerMap, organizerObj := createParticipant(0, uid, pickRandom(options...), "", "")
|
||||
maps[organizerId] = organizerMap
|
||||
objs[organizerId] = organizerObj
|
||||
for i := 1; i < n; i++ {
|
||||
id, _, participantMap, participantObj := createParticipant(i, uid, pickRandom(options...), organizerId, organizerEmail)
|
||||
maps[id] = participantMap
|
||||
objs[id] = participantObj
|
||||
}
|
||||
return maps, objs, organizerEmail
|
||||
}
|
||||
|
||||
func createParticipant(i int, uid string, locationId string, organizerEmail string, organizerId string) (string, string, map[string]any, jscalendar.Participant) {
|
||||
participantId := id()
|
||||
person := gofakeit.Person()
|
||||
roles := RegularRoles
|
||||
if i == 0 {
|
||||
roles = ChairRoles
|
||||
}
|
||||
status := jscalendar.ParticipationStatusAccepted
|
||||
if i != 0 {
|
||||
status = pickRandom(
|
||||
jscalendar.ParticipationStatusNeedsAction,
|
||||
jscalendar.ParticipationStatusAccepted,
|
||||
jscalendar.ParticipationStatusDeclined,
|
||||
jscalendar.ParticipationStatusTentative,
|
||||
)
|
||||
//, delegated + set "delegatedTo"
|
||||
}
|
||||
statusComment := ""
|
||||
if rand.Intn(5) >= 3 {
|
||||
statusComment = gofakeit.HipsterSentence(1 + rand.Intn(5))
|
||||
}
|
||||
if i == 0 {
|
||||
organizerEmail = person.Contact.Email
|
||||
organizerId = participantId
|
||||
}
|
||||
|
||||
name := person.FirstName + " " + person.LastName
|
||||
email := person.Contact.Email
|
||||
description := gofakeit.SentenceSimple()
|
||||
descriptionContentType := pickRandom("text/html", "text/plain")
|
||||
if descriptionContentType == "text/html" {
|
||||
description = toHtml(description)
|
||||
}
|
||||
language := pickLanguage()
|
||||
updated := "2025-10-01T01:59:12Z"
|
||||
updatedTime, err := time.Parse(time.RFC3339, updated)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var calendarAddress string
|
||||
{
|
||||
pos := strings.LastIndex(email, "@")
|
||||
if pos < 0 {
|
||||
calendarAddress = email
|
||||
} else {
|
||||
local := email[0:pos]
|
||||
domain := email[pos+1:]
|
||||
calendarAddress = local + "+itip+" + uid + "@" + "itip." + domain
|
||||
}
|
||||
}
|
||||
|
||||
m := map[string]any{
|
||||
"@type": "Participant",
|
||||
"name": name,
|
||||
"email": email,
|
||||
"calendarAddress": calendarAddress,
|
||||
"kind": "individual",
|
||||
"roles": structs.MapKeys(roles, func(r jscalendar.Role) string { return string(r) }),
|
||||
"locationId": locationId,
|
||||
"language": language,
|
||||
"participationStatus": string(status),
|
||||
"participationComment": statusComment,
|
||||
"expectReply": true,
|
||||
"scheduleAgent": "server",
|
||||
"scheduleSequence": 1,
|
||||
"scheduleStatus": []string{"1.0"},
|
||||
"scheduleUpdated": updated,
|
||||
"sentBy": organizerEmail,
|
||||
"invitedBy": organizerId,
|
||||
"scheduleId": "mailto:" + email,
|
||||
}
|
||||
o := jscalendar.Participant{
|
||||
Type: jscalendar.ParticipantType,
|
||||
Name: name,
|
||||
Email: email,
|
||||
Kind: jscalendar.ParticipantKindIndividual,
|
||||
CalendarAddress: calendarAddress,
|
||||
Roles: roles,
|
||||
LocationId: locationId,
|
||||
Language: language,
|
||||
ParticipationStatus: status,
|
||||
ParticipationComment: statusComment,
|
||||
ExpectReply: true,
|
||||
ScheduleAgent: jscalendar.ScheduleAgentServer,
|
||||
ScheduleSequence: uint(1),
|
||||
ScheduleStatus: []string{"1.0"},
|
||||
ScheduleUpdated: updatedTime,
|
||||
SentBy: organizerEmail,
|
||||
InvitedBy: organizerId,
|
||||
ScheduleId: "mailto:" + email,
|
||||
}
|
||||
|
||||
if EnableEventParticipantDescriptionFields {
|
||||
m["description"] = description
|
||||
m["descriptionContentType"] = descriptionContentType
|
||||
o.Description = description
|
||||
o.DescriptionContentType = descriptionContentType
|
||||
}
|
||||
|
||||
err = propmap(i%2 == 0, 1, 2, m, "links", &o.Links, func(int, string) (map[string]any, jscalendar.Link, error) {
|
||||
href := externalImageUri()
|
||||
title := person.FirstName + "'s Cake Day pick"
|
||||
return map[string]any{
|
||||
"@type": "Link",
|
||||
"href": href,
|
||||
"contentType": "image/jpeg",
|
||||
"rel": "icon",
|
||||
"display": "badge",
|
||||
"title": title,
|
||||
}, jscalendar.Link{
|
||||
Type: jscalendar.LinkType,
|
||||
Href: href,
|
||||
ContentType: "image/jpeg",
|
||||
Rel: jscalendar.RelIcon,
|
||||
Display: jscalendar.DisplayBadge,
|
||||
Title: title,
|
||||
}, nil
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return participantId, person.Contact.Email, m, o
|
||||
}
|
||||
|
||||
var Keywords = []string{
|
||||
"office",
|
||||
"important",
|
||||
"sales",
|
||||
"coordination",
|
||||
"decision",
|
||||
}
|
||||
|
||||
func pickKeywords() map[string]bool {
|
||||
return toBoolMap(pickRandoms(Keywords...))
|
||||
}
|
||||
|
||||
var Categories = []string{
|
||||
"http://opencloud.eu/categories/secret",
|
||||
"http://opencloud.eu/categories/internal",
|
||||
}
|
||||
|
||||
func pickCategories() map[string]bool {
|
||||
return toBoolMap(pickRandoms(Categories...))
|
||||
}
|
||||
1199
pkg/jmap/jmap_integration_test.go
Normal file
1199
pkg/jmap/jmap_integration_test.go
Normal file
File diff suppressed because it is too large
Load Diff
230
pkg/jmap/jmap_integration_ws_test.go
Normal file
230
pkg/jmap/jmap_integration_ws_test.go
Normal file
@@ -0,0 +1,230 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type testWsPushListener struct {
|
||||
t *testing.T
|
||||
logger *log.Logger
|
||||
username string
|
||||
mailAccountId string
|
||||
calls atomic.Uint32
|
||||
m sync.Mutex
|
||||
emailStates []string
|
||||
threadStates []string
|
||||
mailboxStates []string
|
||||
}
|
||||
|
||||
func (l *testWsPushListener) OnNotification(username string, pushState StateChange) {
|
||||
assert.Equal(l.t, l.username, username)
|
||||
l.calls.Add(1)
|
||||
// pushState is currently not supported by Stalwart, let's use the object states instead
|
||||
l.logger.Debug().Msgf("received %T: %v", pushState, pushState)
|
||||
if changed, ok := pushState.Changed[l.mailAccountId]; ok {
|
||||
l.m.Lock()
|
||||
if st, ok := changed[EmailType]; ok {
|
||||
l.emailStates = append(l.emailStates, st)
|
||||
}
|
||||
if st, ok := changed[ThreadType]; ok {
|
||||
l.threadStates = append(l.threadStates, st)
|
||||
}
|
||||
if st, ok := changed[MailboxType]; ok {
|
||||
l.mailboxStates = append(l.mailboxStates, st)
|
||||
}
|
||||
l.m.Unlock()
|
||||
|
||||
unsupportedKeys := structs.Filter(structs.Keys(changed), func(o ObjectType) bool { return o != EmailType && o != ThreadType && o != MailboxType })
|
||||
assert.Empty(l.t, unsupportedKeys)
|
||||
}
|
||||
unsupportedAccounts := structs.Filter(structs.Keys(pushState.Changed), func(s string) bool { return s != l.mailAccountId })
|
||||
assert.Empty(l.t, unsupportedAccounts)
|
||||
}
|
||||
|
||||
var _ WsPushListener = &testWsPushListener{}
|
||||
|
||||
func TestWs(t *testing.T) {
|
||||
if skip(t) {
|
||||
return
|
||||
}
|
||||
|
||||
assert.NoError(t, nil)
|
||||
|
||||
require := require.New(t)
|
||||
|
||||
s, err := newStalwartTest(t)
|
||||
require.NoError(err)
|
||||
defer s.Close()
|
||||
|
||||
user := pickUser()
|
||||
session := s.Session(user.name)
|
||||
|
||||
mailAccountId := session.PrimaryAccounts.Mail
|
||||
inboxFolder := ""
|
||||
{
|
||||
_, inboxFolder = s.findInbox(t, mailAccountId, session)
|
||||
}
|
||||
|
||||
l := &testWsPushListener{t: t, username: user.name, logger: s.logger, mailAccountId: mailAccountId}
|
||||
s.client.AddWsPushListener(l)
|
||||
|
||||
require.Equal(uint32(0), l.calls.Load())
|
||||
{
|
||||
l.m.Lock()
|
||||
require.Len(l.emailStates, 0)
|
||||
require.Len(l.mailboxStates, 0)
|
||||
require.Len(l.threadStates, 0)
|
||||
l.m.Unlock()
|
||||
}
|
||||
|
||||
var initialState State
|
||||
{
|
||||
changes, sessionState, state, _, err := s.client.GetEmailChanges(mailAccountId, session, s.ctx, s.logger, "", "", 0)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.NotEmpty(state)
|
||||
//fmt.Printf("\x1b[45;1;4mChanges [%s]:\x1b[0m\n", state)
|
||||
//for _, c := range changes.Created { fmt.Printf("%s %s\n", c.Id, c.Subject) }
|
||||
initialState = state
|
||||
require.Empty(changes.Created)
|
||||
require.Empty(changes.Destroyed)
|
||||
require.Empty(changes.Updated)
|
||||
}
|
||||
require.NotEmpty(initialState)
|
||||
|
||||
{
|
||||
changes, sessionState, state, _, err := s.client.GetEmailChanges(mailAccountId, session, s.ctx, s.logger, "", initialState, 0)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.Equal(initialState, state)
|
||||
require.Equal(initialState, changes.NewState)
|
||||
require.Empty(changes.Created)
|
||||
require.Empty(changes.Destroyed)
|
||||
require.Empty(changes.Updated)
|
||||
}
|
||||
|
||||
wsc, err := s.client.EnablePushNotifications(initialState, func() (*Session, error) { return session, nil })
|
||||
require.NoError(err)
|
||||
defer wsc.Close()
|
||||
|
||||
require.Equal(uint32(0), l.calls.Load())
|
||||
{
|
||||
l.m.Lock()
|
||||
require.Len(l.emailStates, 0)
|
||||
require.Len(l.mailboxStates, 0)
|
||||
require.Len(l.threadStates, 0)
|
||||
l.m.Unlock()
|
||||
}
|
||||
|
||||
emailIds := []string{}
|
||||
|
||||
{
|
||||
_, n, err := s.fillEmailsWithImap(inboxFolder, 1, false, user)
|
||||
require.NoError(err)
|
||||
require.Equal(1, n)
|
||||
}
|
||||
|
||||
require.Eventually(func() bool {
|
||||
return l.calls.Load() == uint32(1)
|
||||
}, 3*time.Second, 200*time.Millisecond, "WS push listener was not called after first email state change")
|
||||
{
|
||||
l.m.Lock()
|
||||
require.Len(l.emailStates, 1)
|
||||
require.Len(l.mailboxStates, 1)
|
||||
require.Len(l.threadStates, 1)
|
||||
l.m.Unlock()
|
||||
}
|
||||
var lastState State
|
||||
{
|
||||
changes, sessionState, state, _, err := s.client.GetEmailChanges(mailAccountId, session, s.ctx, s.logger, "", initialState, 0)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.NotEqual(initialState, state)
|
||||
require.NotEqual(initialState, changes.NewState)
|
||||
require.Equal(state, changes.NewState)
|
||||
require.Len(changes.Created, 1)
|
||||
require.Empty(changes.Destroyed)
|
||||
require.Empty(changes.Updated)
|
||||
lastState = state
|
||||
|
||||
emailIds = append(emailIds, changes.Created...)
|
||||
}
|
||||
|
||||
{
|
||||
_, n, err := s.fillEmailsWithImap(inboxFolder, 1, false, user)
|
||||
require.NoError(err)
|
||||
require.Equal(1, n)
|
||||
}
|
||||
|
||||
require.Eventually(func() bool {
|
||||
return l.calls.Load() == uint32(2)
|
||||
}, 3*time.Second, 200*time.Millisecond, "WS push listener was not called after second email state change")
|
||||
{
|
||||
l.m.Lock()
|
||||
require.Len(l.emailStates, 2)
|
||||
require.Len(l.mailboxStates, 2)
|
||||
require.Len(l.threadStates, 2)
|
||||
assert.NotEqual(t, l.emailStates[0], l.emailStates[1])
|
||||
assert.NotEqual(t, l.mailboxStates[0], l.mailboxStates[1])
|
||||
assert.NotEqual(t, l.threadStates[0], l.threadStates[1])
|
||||
l.m.Unlock()
|
||||
}
|
||||
{
|
||||
changes, sessionState, state, _, err := s.client.GetEmailChanges(mailAccountId, session, s.ctx, s.logger, "", lastState, 0)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.NotEqual(lastState, state)
|
||||
require.NotEqual(lastState, changes.NewState)
|
||||
require.Equal(state, changes.NewState)
|
||||
require.Len(changes.Created, 1)
|
||||
require.Empty(changes.Destroyed)
|
||||
require.Empty(changes.Updated)
|
||||
lastState = state
|
||||
|
||||
emailIds = append(emailIds, changes.Created...)
|
||||
}
|
||||
|
||||
{
|
||||
_, n, err := s.fillEmailsWithImap(inboxFolder, 0, true, user)
|
||||
require.NoError(err)
|
||||
require.Equal(0, n)
|
||||
}
|
||||
|
||||
require.Eventually(func() bool {
|
||||
return l.calls.Load() == uint32(3)
|
||||
}, 3*time.Second, 200*time.Millisecond, "WS push listener was not called after third email state change")
|
||||
{
|
||||
l.m.Lock()
|
||||
require.Len(l.emailStates, 3)
|
||||
require.Len(l.mailboxStates, 3)
|
||||
require.Len(l.threadStates, 3)
|
||||
assert.NotEqual(t, l.emailStates[1], l.emailStates[2])
|
||||
assert.NotEqual(t, l.mailboxStates[1], l.mailboxStates[2])
|
||||
assert.NotEqual(t, l.threadStates[1], l.threadStates[2])
|
||||
l.m.Unlock()
|
||||
}
|
||||
{
|
||||
changes, sessionState, state, _, err := s.client.GetEmailChanges(mailAccountId, session, s.ctx, s.logger, "", lastState, 0)
|
||||
require.NoError(err)
|
||||
require.Equal(session.State, sessionState)
|
||||
require.NotEqual(lastState, state)
|
||||
require.NotEqual(lastState, changes.NewState)
|
||||
require.Equal(state, changes.NewState)
|
||||
require.Empty(changes.Created)
|
||||
require.Len(changes.Destroyed, 2)
|
||||
require.EqualValues(emailIds, changes.Destroyed)
|
||||
require.Empty(changes.Updated)
|
||||
lastState = state
|
||||
}
|
||||
|
||||
err = wsc.DisableNotifications()
|
||||
require.NoError(err)
|
||||
}
|
||||
6045
pkg/jmap/jmap_model.go
Normal file
6045
pkg/jmap/jmap_model.go
Normal file
File diff suppressed because it is too large
Load Diff
138
pkg/jmap/jmap_session.go
Normal file
138
pkg/jmap/jmap_session.go
Normal file
@@ -0,0 +1,138 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type SessionEventListener interface {
|
||||
OnSessionOutdated(session *Session, newSessionState SessionState)
|
||||
}
|
||||
|
||||
// Cached user related information
|
||||
//
|
||||
// This information is typically retrieved once (or at least for a certain period of time) from the
|
||||
// JMAP well-known endpoint of Stalwart and then kept in cache to avoid the performance cost of
|
||||
// retrieving it over and over again.
|
||||
//
|
||||
// This is really only needed due to the Graph API limitations, since ideally, the account ID should
|
||||
// be passed as a request parameter by the UI, in order to support a user having multiple accounts.
|
||||
//
|
||||
// Keeping track of the JMAP URL might be useful though, in case of Stalwart sharding strategies making
|
||||
// use of that, by providing different URLs for JMAP on a per-user basis, and that is not something
|
||||
// we would want to query before every single JMAP request. On the other hand, that then also creates
|
||||
// a risk of going out-of-sync, e.g. if a node is down and the user is reassigned to a different node.
|
||||
// There might be webhooks to subscribe to in Stalwart to be notified of such situations, in which case
|
||||
// the Session needs to be removed from the cache.
|
||||
//
|
||||
// The Username is only here for convenience, it could just as well be passed as a separate parameter
|
||||
// instead of being part of the Session, since the username is always part of the request (typically in
|
||||
// the authentication token payload.)
|
||||
type Session struct {
|
||||
// The name of the user to use to authenticate against Stalwart
|
||||
Username string
|
||||
|
||||
// The base URL to use for JMAP operations towards Stalwart
|
||||
JmapUrl url.URL
|
||||
// An identifier of the JmapUrl to use in metrics and tracing
|
||||
JmapEndpoint string
|
||||
|
||||
// The upload URL template
|
||||
UploadUrlTemplate string
|
||||
// An identifier of the UploadUrlTemplate to use in metrics and tracing
|
||||
UploadEndpoint string
|
||||
|
||||
// The upload URL template
|
||||
DownloadUrlTemplate string
|
||||
// An identifier of the DownloadUrlTemplate to use in metrics and tracing
|
||||
DownloadEndpoint string
|
||||
|
||||
WebsocketUrl *url.URL
|
||||
SupportsWebsocketPush bool
|
||||
WebsocketEndpoint string
|
||||
|
||||
SessionResponse
|
||||
}
|
||||
|
||||
var (
|
||||
invalidSessionResponseErrorMissingUsername = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response does not provide a username")}
|
||||
invalidSessionResponseErrorMissingApiUrl = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response does not provide an API URL")}
|
||||
invalidSessionResponseErrorInvalidApiUrl = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response provides an invalid API URL")}
|
||||
invalidSessionResponseErrorMissingUploadUrl = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response does not provide an upload URL")}
|
||||
invalidSessionResponseErrorMissingDownloadUrl = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response does not provide a download URL")}
|
||||
invalidSessionResponseErrorInvalidWebsocketUrl = SimpleError{code: JmapErrorInvalidSessionResponse, err: errors.New("JMAP session response provides an invalid Websocket URL")}
|
||||
)
|
||||
|
||||
// Create a new Session from a SessionResponse.
|
||||
func newSession(sessionResponse SessionResponse) (Session, Error) {
|
||||
username := sessionResponse.Username
|
||||
if username == "" {
|
||||
return Session{}, invalidSessionResponseErrorMissingUsername
|
||||
}
|
||||
apiStr := sessionResponse.ApiUrl
|
||||
if apiStr == "" {
|
||||
return Session{}, invalidSessionResponseErrorMissingApiUrl
|
||||
}
|
||||
apiUrl, err := url.Parse(apiStr)
|
||||
if err != nil {
|
||||
return Session{}, invalidSessionResponseErrorInvalidApiUrl
|
||||
}
|
||||
apiEndpoint := endpointOf(apiUrl)
|
||||
|
||||
uploadUrl := sessionResponse.UploadUrl
|
||||
if uploadUrl == "" {
|
||||
return Session{}, invalidSessionResponseErrorMissingUploadUrl
|
||||
}
|
||||
uploadEndpoint := toEndpoint(uploadUrl)
|
||||
|
||||
downloadUrl := sessionResponse.DownloadUrl
|
||||
if downloadUrl == "" {
|
||||
return Session{}, invalidSessionResponseErrorMissingDownloadUrl
|
||||
}
|
||||
downloadEndpoint := toEndpoint(downloadUrl)
|
||||
|
||||
var websocketUrl *url.URL = nil
|
||||
websocketEndpoint := ""
|
||||
supportsWebsocketPush := false
|
||||
websocketUrlStr := sessionResponse.Capabilities.Websocket.Url
|
||||
if websocketUrlStr != "" {
|
||||
websocketUrl, err = url.Parse(websocketUrlStr)
|
||||
if err != nil {
|
||||
return Session{}, invalidSessionResponseErrorInvalidWebsocketUrl
|
||||
}
|
||||
supportsWebsocketPush = sessionResponse.Capabilities.Websocket.SupportsPush
|
||||
websocketEndpoint = endpointOf(websocketUrl)
|
||||
}
|
||||
|
||||
return Session{
|
||||
Username: username,
|
||||
JmapUrl: *apiUrl,
|
||||
JmapEndpoint: apiEndpoint,
|
||||
UploadUrlTemplate: uploadUrl,
|
||||
UploadEndpoint: uploadEndpoint,
|
||||
DownloadUrlTemplate: downloadUrl,
|
||||
DownloadEndpoint: downloadEndpoint,
|
||||
WebsocketUrl: websocketUrl,
|
||||
SupportsWebsocketPush: supportsWebsocketPush,
|
||||
WebsocketEndpoint: websocketEndpoint,
|
||||
SessionResponse: sessionResponse,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func endpointOf(u *url.URL) string {
|
||||
if u != nil {
|
||||
return fmt.Sprintf("%s://%s", u.Scheme, u.Host)
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func toEndpoint(str string) string {
|
||||
u, err := url.Parse(str)
|
||||
if err == nil {
|
||||
return endpointOf(u)
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
336
pkg/jmap/jmap_tools.go
Normal file
336
pkg/jmap/jmap_tools.go
Normal file
@@ -0,0 +1,336 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/opencloud-eu/opencloud/pkg/jscalendar"
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
)
|
||||
|
||||
type eventListeners[T any] struct {
|
||||
listeners []T
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
func (e *eventListeners[T]) add(listener T) {
|
||||
e.m.Lock()
|
||||
defer e.m.Unlock()
|
||||
e.listeners = append(e.listeners, listener)
|
||||
}
|
||||
|
||||
func (e *eventListeners[T]) signal(signal func(T)) {
|
||||
e.m.Lock()
|
||||
defer e.m.Unlock()
|
||||
for _, listener := range e.listeners {
|
||||
signal(listener)
|
||||
}
|
||||
}
|
||||
|
||||
func newEventListeners[T any]() *eventListeners[T] {
|
||||
return &eventListeners[T]{
|
||||
listeners: []T{},
|
||||
}
|
||||
}
|
||||
|
||||
// Create an identifier to use as a method call ID, from the specified accountId and additional
|
||||
// tag, to make something unique within that API request.
|
||||
func mcid(accountId string, tag string) string {
|
||||
// https://jmap.io/spec-core.html#the-invocation-data-type
|
||||
// May be any string of data:
|
||||
// An arbitrary string from the client to be echoed back with the responses emitted by that method
|
||||
// call (a method may return 1 or more responses, as it may make implicit calls to other methods;
|
||||
// all responses initiated by this method call get the same method call id in the response).
|
||||
return accountId + ":" + tag
|
||||
}
|
||||
|
||||
func command[T any](api ApiClient,
|
||||
logger *log.Logger,
|
||||
ctx context.Context,
|
||||
session *Session,
|
||||
sessionOutdatedHandler func(session *Session, newState SessionState),
|
||||
request Request,
|
||||
acceptLanguage string,
|
||||
mapper func(body *Response) (T, State, Error)) (T, SessionState, State, Language, Error) {
|
||||
|
||||
responseBody, language, jmapErr := api.Command(ctx, logger, session, request, acceptLanguage)
|
||||
if jmapErr != nil {
|
||||
var zero T
|
||||
return zero, "", "", language, jmapErr
|
||||
}
|
||||
|
||||
var response Response
|
||||
err := json.Unmarshal(responseBody, &response)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msgf("failed to deserialize body JSON payload into a %T", response)
|
||||
var zero T
|
||||
return zero, "", "", language, SimpleError{code: JmapErrorDecodingResponseBody, err: err}
|
||||
}
|
||||
|
||||
if response.SessionState != session.State {
|
||||
if sessionOutdatedHandler != nil {
|
||||
sessionOutdatedHandler(session, response.SessionState)
|
||||
}
|
||||
}
|
||||
|
||||
// search for an "error" response
|
||||
// https://jmap.io/spec-core.html#method-level-errors
|
||||
for _, mr := range response.MethodResponses {
|
||||
if mr.Command == ErrorCommand {
|
||||
if errorParameters, ok := mr.Parameters.(ErrorResponse); ok {
|
||||
code := JmapErrorServerFail
|
||||
switch errorParameters.Type {
|
||||
case MethodLevelErrorServerUnavailable:
|
||||
code = JmapErrorServerUnavailable
|
||||
case MethodLevelErrorServerFail, MethodLevelErrorServerPartialFail:
|
||||
code = JmapErrorServerFail
|
||||
case MethodLevelErrorUnknownMethod:
|
||||
code = JmapErrorUnknownMethod
|
||||
case MethodLevelErrorInvalidArguments:
|
||||
code = JmapErrorInvalidArguments
|
||||
case MethodLevelErrorInvalidResultReference:
|
||||
code = JmapErrorInvalidResultReference
|
||||
case MethodLevelErrorForbidden:
|
||||
// there's a quirk here: when referencing an account that exists but that this
|
||||
// user has no access to, Stalwart returns the 'forbidden' error, but this might
|
||||
// leak the existence of an account to an attacker -- instead, we deem it safer to
|
||||
// return a "account does not exist" error instead
|
||||
if strings.HasPrefix(errorParameters.Description, "You do not have access to account") {
|
||||
code = JmapErrorAccountNotFound
|
||||
} else {
|
||||
code = JmapErrorForbidden
|
||||
}
|
||||
case MethodLevelErrorAccountNotFound:
|
||||
code = JmapErrorAccountNotFound
|
||||
case MethodLevelErrorAccountNotSupportedByMethod:
|
||||
code = JmapErrorAccountNotSupportedByMethod
|
||||
case MethodLevelErrorAccountReadOnly:
|
||||
code = JmapErrorAccountReadOnly
|
||||
}
|
||||
msg := fmt.Sprintf("found method level error in response '%v', type: '%v', description: '%v'", mr.Tag, errorParameters.Type, errorParameters.Description)
|
||||
err = errors.New(msg)
|
||||
logger.Warn().Int("code", code).Str("type", errorParameters.Type).Msg(msg)
|
||||
var zero T
|
||||
return zero, response.SessionState, "", language, SimpleError{code: code, err: err}
|
||||
} else {
|
||||
code := JmapErrorUnspecifiedType
|
||||
msg := fmt.Sprintf("found method level error in response '%v'", mr.Tag)
|
||||
err := errors.New(msg)
|
||||
logger.Warn().Int("code", code).Msg(msg)
|
||||
var zero T
|
||||
return zero, response.SessionState, "", language, SimpleError{code: code, err: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result, state, jerr := mapper(&response)
|
||||
sessionState := response.SessionState
|
||||
return result, sessionState, state, language, jerr
|
||||
}
|
||||
|
||||
func mapstructStringToTimeHook() mapstructure.DecodeHookFunc {
|
||||
// mapstruct isn't able to properly map RFC3339 date strings into Time
|
||||
// objects, which is why we require this custom hook,
|
||||
// see https://github.com/mitchellh/mapstructure/issues/41
|
||||
wanted := reflect.TypeOf(time.Time{})
|
||||
return func(from reflect.Type, to reflect.Type, data any) (any, error) {
|
||||
if to != wanted {
|
||||
return data, nil
|
||||
}
|
||||
switch from.Kind() {
|
||||
case reflect.String:
|
||||
return time.Parse(time.RFC3339, data.(string))
|
||||
case reflect.Float64:
|
||||
return time.Unix(0, int64(data.(float64))*int64(time.Millisecond)), nil
|
||||
case reflect.Int64:
|
||||
return time.Unix(0, data.(int64)*int64(time.Millisecond)), nil
|
||||
default:
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func decodeMap(input map[string]any, target any) error {
|
||||
// https://github.com/mitchellh/mapstructure/issues/41
|
||||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
Metadata: nil,
|
||||
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
||||
mapstructStringToTimeHook(),
|
||||
jscalendar.MapstructTriggerHook(),
|
||||
),
|
||||
Result: &target,
|
||||
ErrorUnused: false,
|
||||
ErrorUnset: false,
|
||||
IgnoreUntaggedFields: false,
|
||||
Squash: true,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return decoder.Decode(input)
|
||||
}
|
||||
|
||||
func decodeParameters(input any, target any) error {
|
||||
m, ok := input.(map[string]any)
|
||||
if !ok {
|
||||
return fmt.Errorf("decodeParameters: parameters is not a map but a %T", input)
|
||||
}
|
||||
return decodeMap(m, target)
|
||||
}
|
||||
|
||||
func retrieveResponseMatch(data *Response, command Command, tag string) (Invocation, bool) {
|
||||
for _, inv := range data.MethodResponses {
|
||||
if command == inv.Command && tag == inv.Tag {
|
||||
return inv, true
|
||||
}
|
||||
}
|
||||
return Invocation{}, false
|
||||
}
|
||||
|
||||
func retrieveResponseMatchParameters[T any](logger *log.Logger, data *Response, command Command, tag string, target *T) Error {
|
||||
match, ok := retrieveResponseMatch(data, command, tag)
|
||||
if !ok {
|
||||
err := fmt.Errorf("failed to find JMAP response invocation match for command '%v' and tag '%v'", command, tag)
|
||||
logger.Error().Msg(err.Error())
|
||||
return simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
params := match.Parameters
|
||||
typedParams, ok := params.(T)
|
||||
if !ok {
|
||||
err := fmt.Errorf("JMAP response invocation matches command '%v' and tag '%v' but the type %T does not match the expected %T", command, tag, params, *target)
|
||||
logger.Error().Msg(err.Error())
|
||||
return simpleError(err, JmapErrorInvalidJmapResponsePayload)
|
||||
}
|
||||
*target = typedParams
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Invocation) MarshalJSON() ([]byte, error) {
|
||||
// JMAP requests have a slightly unusual structure since they are not a JSON object
|
||||
// but, instead, a three-element array composed of
|
||||
// 0: the command (e.g. "Email/query")
|
||||
// 1: the actual payload of the request (structure depends on the command)
|
||||
// 2: a tag that can be used to identify the matching response payload
|
||||
// That implementation aspect thus requires us to use a custom marshalling hook.
|
||||
arr := []any{string(i.Command), i.Parameters, i.Tag}
|
||||
return json.Marshal(arr)
|
||||
}
|
||||
|
||||
func (i *Invocation) UnmarshalJSON(bs []byte) error {
|
||||
// JMAP responses have a slightly unusual structure since they are not a JSON object
|
||||
// but, instead, a three-element array composed of
|
||||
// 0: the command (e.g. "Thread/get") this is a response to
|
||||
// 1: the actual payload of the response (structure depends on the command)
|
||||
// 2: the tag (same as in the request invocation)
|
||||
// That implementation aspect thus requires us to use a custom unmarshalling hook.
|
||||
arr := []any{}
|
||||
err := json.Unmarshal(bs, &arr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(arr) != 3 {
|
||||
// JMAP response must really always be an array of three elements
|
||||
return fmt.Errorf("Invocation array length ought to be 3 but is %d", len(arr))
|
||||
}
|
||||
// The first element in the array is the command:
|
||||
i.Command = Command(arr[0].(string))
|
||||
// The third element in the array is the tag:
|
||||
i.Tag = arr[2].(string)
|
||||
|
||||
// Due to the dynamic nature of request and response types in JMAP, we
|
||||
// switch to using mapstruct here to deserialize the payload in the "parameters"
|
||||
// element of JMAP invocation response arrays, as their expected struct type
|
||||
// is directly inferred from the command (e.g. "Mailbox/get")
|
||||
payload := arr[1]
|
||||
|
||||
paramsFactory, ok := CommandResponseTypeMap[i.Command]
|
||||
if !ok {
|
||||
return fmt.Errorf("unsupported JMAP operation cannot be unmarshalled: %v", i.Command)
|
||||
}
|
||||
params := paramsFactory()
|
||||
err = decodeParameters(payload, ¶ms)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.Parameters = params
|
||||
return nil
|
||||
}
|
||||
|
||||
func squashState(all map[string]State) State {
|
||||
return squashStateFunc(all, func(s State) State { return s })
|
||||
}
|
||||
|
||||
func squashStateFunc[V any](all map[string]V, mapper func(V) State) State {
|
||||
n := len(all)
|
||||
if n == 0 {
|
||||
return State("")
|
||||
}
|
||||
if n == 1 {
|
||||
for _, v := range all {
|
||||
return mapper(v)
|
||||
}
|
||||
}
|
||||
|
||||
parts := make([]string, n)
|
||||
sortedKeys := make([]string, n)
|
||||
i := 0
|
||||
for k := range all {
|
||||
sortedKeys[i] = k
|
||||
i++
|
||||
}
|
||||
slices.Sort(sortedKeys)
|
||||
for i, k := range sortedKeys {
|
||||
if v, ok := all[k]; ok {
|
||||
parts[i] = k + ":" + string(mapper(v))
|
||||
} else {
|
||||
parts[i] = k + ":"
|
||||
}
|
||||
}
|
||||
return State(strings.Join(parts, ","))
|
||||
}
|
||||
|
||||
func squashStateMaps(first map[string]State, second map[string]State) State {
|
||||
return squashStateFunc(mapPairs(first, second), func(p pair[State, State]) State {
|
||||
if p.left != nil {
|
||||
if p.right != nil {
|
||||
return *p.left + ";" + *p.right
|
||||
} else {
|
||||
return *p.left + ";"
|
||||
}
|
||||
} else if p.right != nil {
|
||||
return ";" + *p.right
|
||||
} else {
|
||||
return ";"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type pair[L any, R any] struct {
|
||||
left *L
|
||||
right *R
|
||||
}
|
||||
|
||||
func mapPairs[K comparable, L, R any](left map[K]L, right map[K]R) map[K]pair[L, R] {
|
||||
result := map[K]pair[L, R]{}
|
||||
for k, l := range left {
|
||||
if r, ok := right[k]; ok {
|
||||
result[k] = pair[L, R]{left: &l, right: &r}
|
||||
} else {
|
||||
result[k] = pair[L, R]{left: &l, right: nil}
|
||||
}
|
||||
}
|
||||
for k, r := range right {
|
||||
if _, ok := left[k]; !ok {
|
||||
result[k] = pair[L, R]{left: nil, right: &r}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
24
pkg/jmap/jmap_tools_test.go
Normal file
24
pkg/jmap/jmap_tools_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package jmap
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestUnmarshallingError(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
responseBody := `{"methodResponses":[["error",{"type":"forbidden","description":"You do not have access to account a"},"a:0"]],"sessionState":"3e25b2a0"}`
|
||||
var response Response
|
||||
err := json.Unmarshal([]byte(responseBody), &response)
|
||||
require.NoError(err)
|
||||
require.Len(response.MethodResponses, 1)
|
||||
require.Equal(ErrorCommand, response.MethodResponses[0].Command)
|
||||
require.Equal("a:0", response.MethodResponses[0].Tag)
|
||||
require.IsType(ErrorResponse{}, response.MethodResponses[0].Parameters)
|
||||
er, _ := response.MethodResponses[0].Parameters.(ErrorResponse)
|
||||
require.Equal("forbidden", er.Type)
|
||||
require.Equal("You do not have access to account a", er.Description)
|
||||
}
|
||||
2277
pkg/jscalendar/jscalendar_model.go
Normal file
2277
pkg/jscalendar/jscalendar_model.go
Normal file
File diff suppressed because it is too large
Load Diff
716
pkg/jscalendar/jscalendar_model_test.go
Normal file
716
pkg/jscalendar/jscalendar_model_test.go
Normal file
@@ -0,0 +1,716 @@
|
||||
package jscalendar
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func jsoneq[X any](t *testing.T, expected string, object X) {
|
||||
data, err := json.MarshalIndent(object, "", "")
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, expected, string(data))
|
||||
|
||||
var rec X
|
||||
err = json.Unmarshal(data, &rec)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, object, rec)
|
||||
}
|
||||
|
||||
/*
|
||||
func TestLocalDateTime(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
|
||||
ldt := &LocalDateTime{ts}
|
||||
|
||||
str, err := json.MarshalIndent(ldt, "", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "\"2025-09-25T16:26:14\"", string(str))
|
||||
}
|
||||
|
||||
func TestLocalDateTimeUnmarshalling(t *testing.T) {
|
||||
ts, err := time.Parse(RFC3339Local, "2025-09-25T18:26:14")
|
||||
require.NoError(t, err)
|
||||
u := ts.UTC()
|
||||
|
||||
var result LocalDateTime
|
||||
err = json.Unmarshal([]byte("\"2025-09-25T18:26:14Z\""), &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, result, LocalDateTime{u})
|
||||
}
|
||||
*/
|
||||
|
||||
func TestRelation(t *testing.T) {
|
||||
jsoneq(t, `{
|
||||
"@type": "Relation",
|
||||
"relation": {
|
||||
"first": true,
|
||||
"parent": true
|
||||
}
|
||||
}`, Relation{
|
||||
Type: RelationType,
|
||||
Relation: map[Relationship]bool{
|
||||
RelationshipFirst: true,
|
||||
RelationshipParent: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestLink(t *testing.T) {
|
||||
jsoneq(t, `{
|
||||
"@type": "Link",
|
||||
"href": "https://opencloud.eu.example.com/f72ae875-40be-48a4-84ff-aea9aed3e085.png",
|
||||
"contentType": "image/png",
|
||||
"size": 128912,
|
||||
"rel": "icon",
|
||||
"display": "thumbnail",
|
||||
"title": "the logo"
|
||||
}`, Link{
|
||||
Type: LinkType,
|
||||
Href: "https://opencloud.eu.example.com/f72ae875-40be-48a4-84ff-aea9aed3e085.png",
|
||||
ContentType: "image/png",
|
||||
Size: 128912,
|
||||
Rel: RelIcon,
|
||||
Display: DisplayThumbnail,
|
||||
Title: "the logo",
|
||||
})
|
||||
}
|
||||
|
||||
func TestLocation(t *testing.T) {
|
||||
jsoneq(t, `{
|
||||
"@type": "Location",
|
||||
"name": "The Eiffel Tower",
|
||||
"locationTypes": {
|
||||
"landmark-address": true,
|
||||
"industrial": true
|
||||
},
|
||||
"coordinates": "geo:48.8559324,2.2932441",
|
||||
"links": {
|
||||
"l1": {
|
||||
"@type": "Link",
|
||||
"href": "https://upload.wikimedia.org/wikipedia/commons/f/fd/Eiffel_blue.PNG",
|
||||
"contentType": "image/png",
|
||||
"size": 12345,
|
||||
"rel": "icon",
|
||||
"display": "A blue Eiffel tower",
|
||||
"title": "Blue Eiffel Tower"
|
||||
}
|
||||
}
|
||||
}`, Location{
|
||||
Type: LocationType,
|
||||
Name: "The Eiffel Tower",
|
||||
LocationTypes: map[LocationTypeOption]bool{
|
||||
LocationTypeOptionLandmarkAddress: true,
|
||||
LocationTypeOptionIndustrial: true,
|
||||
},
|
||||
Coordinates: "geo:48.8559324,2.2932441",
|
||||
Links: map[string]Link{
|
||||
"l1": {
|
||||
Type: LinkType,
|
||||
Href: "https://upload.wikimedia.org/wikipedia/commons/f/fd/Eiffel_blue.PNG",
|
||||
ContentType: "image/png",
|
||||
Size: 12345,
|
||||
Rel: RelIcon,
|
||||
Display: "A blue Eiffel tower",
|
||||
Title: "Blue Eiffel Tower",
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestVirtualLocation(t *testing.T) {
|
||||
jsoneq(t, `{
|
||||
"@type": "VirtualLocation",
|
||||
"name": "OpenTalk",
|
||||
"uri": "https://opentalk.eu",
|
||||
"features": {
|
||||
"video": true,
|
||||
"screen": true,
|
||||
"audio": true
|
||||
}
|
||||
}`, VirtualLocation{
|
||||
Type: VirtualLocationType,
|
||||
Name: "OpenTalk",
|
||||
Uri: "https://opentalk.eu",
|
||||
Features: map[VirtualLocationFeature]bool{
|
||||
VirtualLocationFeatureVideo: true,
|
||||
VirtualLocationFeatureScreen: true,
|
||||
VirtualLocationFeatureAudio: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestNDay(t *testing.T) {
|
||||
jsoneq(t, `{
|
||||
"@type": "NDay",
|
||||
"day": "fr",
|
||||
"nthOfPeriod": -1
|
||||
}`, NDay{
|
||||
Type: NDayType,
|
||||
Day: DayOfWeekFriday,
|
||||
NthOfPeriod: -1,
|
||||
})
|
||||
}
|
||||
|
||||
func TestRecurrenceRule(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
l := LocalDateTime("2025-09-25T16:26:14")
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "RecurrenceRule",
|
||||
"frequency": "daily",
|
||||
"interval": 1,
|
||||
"rscale": "iso8601",
|
||||
"skip": "forward",
|
||||
"firstDayOfWeek": "mo",
|
||||
"byDay": [
|
||||
{"@type": "NDay", "day": "mo", "nthOfPeriod": -1},
|
||||
{"@type": "NDay", "day": "tu"},
|
||||
{"day": "we"}
|
||||
],
|
||||
"byMonthDay": [1, 10, 31],
|
||||
"byMonth": ["1", "31L"],
|
||||
"byYearDay": [-1, 366],
|
||||
"byWeekNo": [-53, 53],
|
||||
"byHour": [0, 23],
|
||||
"byMinute": [0, 59],
|
||||
"bySecond": [0, 39],
|
||||
"bySetPosition": [-3, 3],
|
||||
"count": 2,
|
||||
"until": "2025-09-25T16:26:14"
|
||||
}`, RecurrenceRule{
|
||||
Type: RecurrenceRuleType,
|
||||
Frequency: FrequencyDaily,
|
||||
Interval: 1,
|
||||
Rscale: RscaleIso8601,
|
||||
Skip: SkipForward,
|
||||
FirstDayOfWeek: DayOfWeekMonday,
|
||||
ByDay: []NDay{
|
||||
{
|
||||
Type: NDayType,
|
||||
Day: DayOfWeekMonday,
|
||||
NthOfPeriod: -1,
|
||||
},
|
||||
{
|
||||
Type: NDayType,
|
||||
Day: DayOfWeekTuesday,
|
||||
},
|
||||
{
|
||||
Day: DayOfWeekWednesday,
|
||||
NthOfPeriod: 0,
|
||||
},
|
||||
},
|
||||
ByMonthDay: []int{1, 10, 31},
|
||||
ByMonth: []string{"1", "31L"},
|
||||
ByYearDay: []int{-1, 366},
|
||||
ByWeekNo: []int{-53, 53},
|
||||
ByHour: []uint{0, 23},
|
||||
ByMinute: []uint{0, 59},
|
||||
BySecond: []uint{0, 39},
|
||||
BySetPosition: []int{-3, 3},
|
||||
Count: 2,
|
||||
Until: &l,
|
||||
})
|
||||
}
|
||||
|
||||
func TestParticipant(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
|
||||
ts2, err := time.Parse(time.RFC3339, "2025-09-29T14:32:19+02:00")
|
||||
require.NoError(t, err)
|
||||
ts2 = ts2.UTC()
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "Participant",
|
||||
"name": "Camina Drummer",
|
||||
"email": "camina@opa.org",
|
||||
"description": "Camina Drummer is a Belter serving as the current President of the Transport Union.",
|
||||
"calendarAddress": "cdrummer@itip.opa.org",
|
||||
"kind": "individual",
|
||||
"roles": {
|
||||
"owner": true,
|
||||
"chair": true
|
||||
},
|
||||
"locationId": "98faaa01-b6db-4ddb-9574-e28ab83104e6",
|
||||
"language": "en-JM",
|
||||
"participationStatus": "accepted",
|
||||
"participationComment": "always there",
|
||||
"expectReply": true,
|
||||
"scheduleAgent": "server",
|
||||
"scheduleForceSend": true,
|
||||
"scheduleSequence": 3,
|
||||
"scheduleStatus": [
|
||||
"3.1",
|
||||
"2.0"
|
||||
],
|
||||
"scheduleUpdated": "2025-09-25T16:26:14Z",
|
||||
"sentBy": "adawes@opa.org",
|
||||
"invitedBy": "346be402-c340-4f3f-ac51-e4aa9955af4f",
|
||||
"delegatedTo": {
|
||||
"93230b90-70c6-4027-b2c1-3629877bfea5": true,
|
||||
"f5fae398-cfa3-4873-bbc7-0ca9d51de5b0": true
|
||||
},
|
||||
"delegatedFrom": {
|
||||
"a9c1c1a1-fecf-4214-a803-1ee209e2dbec": true
|
||||
},
|
||||
"memberOf": {
|
||||
"0f41473b-0edd-494d-b346-8d039009a2a5": true
|
||||
},
|
||||
"links":{
|
||||
"l1": {
|
||||
"@type": "Link",
|
||||
"href": "https://opa.org/opa.png",
|
||||
"contentType": "image/png",
|
||||
"size": 182912,
|
||||
"rel": "icon",
|
||||
"display": "Logo",
|
||||
"title": "OPA"
|
||||
}
|
||||
},
|
||||
"progress": "in-process",
|
||||
"progressUpdated": "2025-09-29T12:32:19Z",
|
||||
"percentComplete": 42
|
||||
}`, Participant{
|
||||
Type: ParticipantType,
|
||||
Name: "Camina Drummer",
|
||||
Email: "camina@opa.org",
|
||||
Description: "Camina Drummer is a Belter serving as the current President of the Transport Union.",
|
||||
CalendarAddress: "cdrummer@itip.opa.org",
|
||||
Kind: ParticipantKindIndividual,
|
||||
Roles: map[Role]bool{
|
||||
RoleOwner: true,
|
||||
RoleChair: true,
|
||||
},
|
||||
LocationId: "98faaa01-b6db-4ddb-9574-e28ab83104e6",
|
||||
Language: "en-JM",
|
||||
ParticipationStatus: ParticipationStatusAccepted,
|
||||
ParticipationComment: "always there",
|
||||
ExpectReply: true,
|
||||
ScheduleAgent: ScheduleAgentServer,
|
||||
ScheduleForceSend: true,
|
||||
ScheduleSequence: 3,
|
||||
ScheduleStatus: []string{
|
||||
"3.1",
|
||||
"2.0",
|
||||
},
|
||||
ScheduleUpdated: ts,
|
||||
SentBy: "adawes@opa.org",
|
||||
InvitedBy: "346be402-c340-4f3f-ac51-e4aa9955af4f",
|
||||
DelegatedTo: map[string]bool{
|
||||
"93230b90-70c6-4027-b2c1-3629877bfea5": true,
|
||||
"f5fae398-cfa3-4873-bbc7-0ca9d51de5b0": true,
|
||||
},
|
||||
DelegatedFrom: map[string]bool{
|
||||
"a9c1c1a1-fecf-4214-a803-1ee209e2dbec": true,
|
||||
},
|
||||
MemberOf: map[string]bool{
|
||||
"0f41473b-0edd-494d-b346-8d039009a2a5": true,
|
||||
},
|
||||
Links: map[string]Link{
|
||||
"l1": {
|
||||
Type: LinkType,
|
||||
Href: "https://opa.org/opa.png",
|
||||
ContentType: "image/png",
|
||||
Size: 182912,
|
||||
Rel: RelIcon,
|
||||
Display: "Logo",
|
||||
Title: "OPA",
|
||||
},
|
||||
},
|
||||
Progress: ProgressInProcess,
|
||||
ProgressUpdated: ts2,
|
||||
PercentComplete: 42,
|
||||
})
|
||||
}
|
||||
|
||||
func TestAlertWithAbsoluteTrigger(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "Alert",
|
||||
"trigger": {
|
||||
"@type": "AbsoluteTrigger",
|
||||
"when": "2025-09-25T16:26:14Z"
|
||||
},
|
||||
"acknowledged": "2025-09-25T16:26:14Z",
|
||||
"relatedTo": {
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
"@type": "Relation",
|
||||
"relation": {
|
||||
"first": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"action": "email"
|
||||
}`, Alert{
|
||||
Type: AlertType,
|
||||
Trigger: &AbsoluteTrigger{
|
||||
Type: AbsoluteTriggerType,
|
||||
When: ts,
|
||||
},
|
||||
Acknowledged: ts,
|
||||
RelatedTo: map[string]Relation{
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
Type: RelationType,
|
||||
Relation: map[Relationship]bool{
|
||||
RelationshipFirst: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Action: AlertActionEmail,
|
||||
})
|
||||
}
|
||||
|
||||
func TestAlertWithOffsetTrigger(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "Alert",
|
||||
"trigger": {
|
||||
"@type": "OffsetTrigger",
|
||||
"offset": "-PT5M",
|
||||
"relativeTo": "end"
|
||||
},
|
||||
"acknowledged": "2025-09-25T16:26:14Z",
|
||||
"relatedTo": {
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
"@type": "Relation",
|
||||
"relation": {
|
||||
"first": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"action": "email"
|
||||
}`, Alert{
|
||||
Type: AlertType,
|
||||
Trigger: &OffsetTrigger{
|
||||
Type: OffsetTriggerType,
|
||||
Offset: "-PT5M",
|
||||
RelativeTo: RelativeToEnd,
|
||||
},
|
||||
Acknowledged: ts,
|
||||
RelatedTo: map[string]Relation{
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
Type: RelationType,
|
||||
Relation: map[Relationship]bool{
|
||||
RelationshipFirst: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Action: AlertActionEmail,
|
||||
})
|
||||
}
|
||||
|
||||
func TestAlertWithUnknownTrigger(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T18:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "Alert",
|
||||
"trigger": {
|
||||
"@type": "XYZTRIGGER",
|
||||
"abc": 123,
|
||||
"xyz": "zzz"
|
||||
},
|
||||
"acknowledged": "2025-09-25T16:26:14Z",
|
||||
"relatedTo": {
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
"@type": "Relation",
|
||||
"relation": {
|
||||
"first": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"action": "email"
|
||||
}`, Alert{
|
||||
Type: AlertType,
|
||||
Trigger: &UnknownTrigger{
|
||||
"@type": "XYZTRIGGER",
|
||||
"abc": 123.0,
|
||||
"xyz": "zzz",
|
||||
},
|
||||
Acknowledged: ts,
|
||||
RelatedTo: map[string]Relation{
|
||||
"a2e729eb-7d9c-4ea7-8514-93d2590ef0a2": {
|
||||
Type: RelationType,
|
||||
Relation: map[Relationship]bool{
|
||||
RelationshipFirst: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Action: AlertActionEmail,
|
||||
})
|
||||
}
|
||||
|
||||
func TestTimeZoneRule(t *testing.T) {
|
||||
l1 := LocalDateTime("2025-09-25T16:26:14")
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "TimeZoneRule",
|
||||
"start": "2025-09-25T16:26:14",
|
||||
"offsetFrom": "-0200",
|
||||
"offsetTo": "+0200",
|
||||
"recurrenceRules": [
|
||||
{
|
||||
"@type": "RecurrenceRule",
|
||||
"frequency": "weekly",
|
||||
"interval": 2,
|
||||
"rscale": "iso8601",
|
||||
"skip": "omit",
|
||||
"firstDayOfWeek": "mo",
|
||||
"byDay": [
|
||||
{
|
||||
"@type": "NDay",
|
||||
"day": "fr"
|
||||
}
|
||||
],
|
||||
"byHour": [14],
|
||||
"byMinute": [0],
|
||||
"count": 4
|
||||
}
|
||||
],
|
||||
"recurrenceOverrides": {
|
||||
"2025-09-25T16:26:14": {}
|
||||
},
|
||||
"names": {
|
||||
"CEST": true
|
||||
},
|
||||
"comments": ["this is a comment"]
|
||||
}`, TimeZoneRule{
|
||||
Type: TimeZoneRuleType,
|
||||
Start: l1,
|
||||
OffsetFrom: "-0200",
|
||||
OffsetTo: "+0200",
|
||||
RecurrenceRules: []RecurrenceRule{
|
||||
{
|
||||
Type: RecurrenceRuleType,
|
||||
Frequency: FrequencyWeekly,
|
||||
Interval: 2,
|
||||
Rscale: RscaleIso8601,
|
||||
Skip: SkipOmit,
|
||||
FirstDayOfWeek: DayOfWeekMonday,
|
||||
ByDay: []NDay{
|
||||
{
|
||||
Type: NDayType,
|
||||
Day: DayOfWeekFriday,
|
||||
},
|
||||
},
|
||||
ByHour: []uint{
|
||||
14,
|
||||
},
|
||||
ByMinute: []uint{
|
||||
0,
|
||||
},
|
||||
Count: 4,
|
||||
},
|
||||
},
|
||||
RecurrenceOverrides: map[LocalDateTime]PatchObject{
|
||||
l1: {},
|
||||
},
|
||||
Names: map[string]bool{
|
||||
"CEST": true,
|
||||
},
|
||||
Comments: []string{
|
||||
"this is a comment",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestTimeZone(t *testing.T) {
|
||||
ts, err := time.Parse(time.RFC3339, "2025-09-25T16:26:14+02:00")
|
||||
require.NoError(t, err)
|
||||
ts = ts.UTC()
|
||||
l := LocalDateTime("2025-09-25T16:26:14")
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "TimeZone",
|
||||
"tzId": "cest",
|
||||
"updated": "2025-09-25T14:26:14Z",
|
||||
"url": "https://timezones.net/cest",
|
||||
"validUntil": "2025-09-25T14:26:14Z",
|
||||
"aliases": {
|
||||
"cet": true
|
||||
},
|
||||
"standard": [{
|
||||
"@type": "TimeZoneRule",
|
||||
"start": "2025-09-25T16:26:14",
|
||||
"offsetFrom": "-0200",
|
||||
"offsetTo": "+1245"
|
||||
}],
|
||||
"daylight": [{
|
||||
"@type": "TimeZoneRule",
|
||||
"start": "2025-09-25T16:26:14",
|
||||
"offsetFrom": "-0200",
|
||||
"offsetTo": "+1245"
|
||||
}]
|
||||
}`, TimeZone{
|
||||
Type: TimeZoneType,
|
||||
TzId: "cest",
|
||||
Updated: ts,
|
||||
Url: "https://timezones.net/cest",
|
||||
ValidUntil: ts,
|
||||
Aliases: map[string]bool{
|
||||
"cet": true,
|
||||
},
|
||||
Standard: []TimeZoneRule{
|
||||
{
|
||||
Type: TimeZoneRuleType,
|
||||
Start: l,
|
||||
OffsetFrom: "-0200",
|
||||
OffsetTo: "+1245",
|
||||
},
|
||||
},
|
||||
Daylight: []TimeZoneRule{
|
||||
{
|
||||
Type: TimeZoneRuleType,
|
||||
Start: l,
|
||||
OffsetFrom: "-0200",
|
||||
OffsetTo: "+1245",
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestEvent(t *testing.T) {
|
||||
local1 := "2025-09-25T16:26:14"
|
||||
ts1, err := time.Parse(time.RFC3339, local1+"+02:00")
|
||||
require.NoError(t, err)
|
||||
ts1 = ts1.UTC()
|
||||
|
||||
local2 := "2025-09-29T13:53:01"
|
||||
ts2, err := time.Parse(time.RFC3339, local2+"+02:00")
|
||||
require.NoError(t, err)
|
||||
ts2 = ts2.UTC()
|
||||
|
||||
l := LocalDateTime("2025-09-25T16:26:14")
|
||||
|
||||
jsoneq(t, `{
|
||||
"@type": "Event",
|
||||
"start": "2025-09-25T16:26:14",
|
||||
"duration": "PT10M",
|
||||
"status": "confirmed",
|
||||
"uid": "b422cfec-f7b4-4e04-8ec6-b794007f63f1",
|
||||
"prodId": "OpenCloud 1.0",
|
||||
"created": "2025-09-25T16:26:14",
|
||||
"updated": "2025-09-29T13:53:01",
|
||||
"title": "End of year party",
|
||||
"description": "It's the party at the end of the year.",
|
||||
"descriptionContentType": "text/plain",
|
||||
"links": {
|
||||
"l1": {
|
||||
"@type": "Link",
|
||||
"href": "https://opencloud.eu/eoy-party/2025",
|
||||
"contentType": "text/html",
|
||||
"rel": "about"
|
||||
}
|
||||
},
|
||||
"locale": "en-GB",
|
||||
"keywords": {
|
||||
"k1": true
|
||||
},
|
||||
"categories": {
|
||||
"cat": true
|
||||
},
|
||||
"color": "oil",
|
||||
"relatedTo": {
|
||||
"a": {
|
||||
"@type": "Relation",
|
||||
"relation": {
|
||||
"next": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"sequence": 3,
|
||||
"showWithoutTime": true,
|
||||
"locations": {
|
||||
"loc1": {
|
||||
"@type": "Location",
|
||||
"name": "Steel Cactus Mexican Grill",
|
||||
"locationTypes": {
|
||||
"bar": true
|
||||
},
|
||||
"coordinates": "geo:16.7685657,-4.8629852",
|
||||
"links": {
|
||||
"l1": {
|
||||
"@type": "Link",
|
||||
"href": "https://mars.gov/bars/steelcactus",
|
||||
"rel": "about"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`, Event{
|
||||
Type: EventType,
|
||||
Start: l,
|
||||
Duration: "PT10M",
|
||||
Status: "confirmed",
|
||||
Object: Object{
|
||||
CommonObject: CommonObject{
|
||||
Uid: "b422cfec-f7b4-4e04-8ec6-b794007f63f1",
|
||||
ProdId: "OpenCloud 1.0",
|
||||
Created: UTCDateTime(local1),
|
||||
Updated: UTCDateTime(local2),
|
||||
Title: "End of year party",
|
||||
Description: "It's the party at the end of the year.",
|
||||
DescriptionContentType: "text/plain",
|
||||
Links: map[string]Link{
|
||||
"l1": {
|
||||
Type: LinkType,
|
||||
Href: "https://opencloud.eu/eoy-party/2025",
|
||||
ContentType: "text/html",
|
||||
Rel: RelAbout,
|
||||
},
|
||||
},
|
||||
Locale: "en-GB",
|
||||
Keywords: map[string]bool{
|
||||
"k1": true,
|
||||
},
|
||||
Categories: map[string]bool{
|
||||
"cat": true,
|
||||
},
|
||||
Color: "oil",
|
||||
},
|
||||
RelatedTo: map[string]Relation{
|
||||
"a": {
|
||||
Type: RelationType,
|
||||
Relation: map[Relationship]bool{
|
||||
RelationshipNext: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Sequence: 3,
|
||||
ShowWithoutTime: true,
|
||||
Locations: map[string]Location{
|
||||
"loc1": {
|
||||
Type: LocationType,
|
||||
Name: "Steel Cactus Mexican Grill",
|
||||
LocationTypes: map[LocationTypeOption]bool{
|
||||
LocationTypeOptionBar: true,
|
||||
},
|
||||
Coordinates: "geo:16.7685657,-4.8629852",
|
||||
Links: map[string]Link{
|
||||
"l1": {
|
||||
Type: LinkType,
|
||||
Href: "https://mars.gov/bars/steelcactus",
|
||||
Rel: RelAbout,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
2450
pkg/jscontact/jscontact_model.go
Normal file
2450
pkg/jscontact/jscontact_model.go
Normal file
File diff suppressed because it is too large
Load Diff
1252
pkg/jscontact/jscontact_model_test.go
Normal file
1252
pkg/jscontact/jscontact_model_test.go
Normal file
File diff suppressed because it is too large
Load Diff
59
pkg/log/log_safely.go
Normal file
59
pkg/log/log_safely.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package log
|
||||
|
||||
import "github.com/rs/zerolog"
|
||||
|
||||
const (
|
||||
logMaxStrLength = 512
|
||||
logMaxStrArrayLength = 16 // 8kb
|
||||
)
|
||||
|
||||
// Safely caps a string to a given size to avoid log bombing.
|
||||
// Use this function to wrap strings that are user input (HTTP headers, path parameters, URI parameters, HTTP body, ...).
|
||||
func SafeString(text string) string {
|
||||
runes := []rune(text)
|
||||
|
||||
if len(runes) <= logMaxStrLength {
|
||||
return text
|
||||
} else {
|
||||
return string(runes[0:logMaxStrLength-1]) + `\u2026` // hellip
|
||||
}
|
||||
}
|
||||
|
||||
type SafeLogStringArrayMarshaller struct {
|
||||
array []string
|
||||
}
|
||||
|
||||
func (m SafeLogStringArrayMarshaller) MarshalZerologArray(a *zerolog.Array) {
|
||||
for i, elem := range m.array {
|
||||
if i >= logMaxStrArrayLength {
|
||||
return
|
||||
}
|
||||
a.Str(SafeString(elem))
|
||||
}
|
||||
}
|
||||
|
||||
var _ zerolog.LogArrayMarshaler = SafeLogStringArrayMarshaller{}
|
||||
|
||||
func SafeStringArray(array []string) SafeLogStringArrayMarshaller {
|
||||
return SafeLogStringArrayMarshaller{array: array}
|
||||
}
|
||||
|
||||
type StringArrayMarshaller struct {
|
||||
array []string
|
||||
}
|
||||
|
||||
func (m StringArrayMarshaller) MarshalZerologArray(a *zerolog.Array) {
|
||||
for _, elem := range m.array {
|
||||
a.Str(elem)
|
||||
}
|
||||
}
|
||||
|
||||
var _ zerolog.LogArrayMarshaler = StringArrayMarshaller{}
|
||||
|
||||
func StringArray(array []string) StringArrayMarshaller {
|
||||
return StringArrayMarshaller{array: array}
|
||||
}
|
||||
|
||||
func From(context zerolog.Context) *Logger {
|
||||
return &Logger{Logger: context.Logger()}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/shared"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -24,7 +23,7 @@ type Options struct {
|
||||
Address string
|
||||
Handler http.Handler
|
||||
Context context.Context
|
||||
Flags []pflag.Flag
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ func Context(ctx context.Context) Option {
|
||||
}
|
||||
|
||||
// Flags provides a function to set the flags option.
|
||||
func Flags(flags ...pflag.Flag) Option {
|
||||
func Flags(flags ...cli.Flag) Option {
|
||||
return func(o *Options) {
|
||||
o.Flags = append(o.Flags, flags...)
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ func NewService(opts ...Option) (Service, error) {
|
||||
}
|
||||
tlsConfig := &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
MinVersion: tls.VersionTLS12,
|
||||
NextProtos: []string{"h2", "http/1.1"},
|
||||
}
|
||||
mServer = mhttps.NewServer(server.TLSConfig(tlsConfig))
|
||||
} else {
|
||||
@@ -64,8 +62,7 @@ func NewService(opts ...Option) (Service, error) {
|
||||
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
|
||||
micro.Version(sopts.Version),
|
||||
micro.Context(sopts.Context),
|
||||
// TODO: clarify if this is actually used on the go-micro side
|
||||
//micro.Flags(sopts.Flags...),
|
||||
micro.Flags(sopts.Flags...),
|
||||
micro.Registry(registry.GetRegistry()),
|
||||
micro.RegisterTTL(registry.GetRegisterTTL()),
|
||||
micro.RegisterInterval(registry.GetRegisterInterval()),
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
// Package structs provides some utility functions for dealing with structs.
|
||||
package structs
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
orderedmap "github.com/wk8/go-ordered-map"
|
||||
)
|
||||
|
||||
// CopyOrZeroValue returns a copy of s if s is not nil otherwise the zero value of T will be returned.
|
||||
func CopyOrZeroValue[T any](s *T) *T {
|
||||
cp := new(T)
|
||||
@@ -9,3 +16,238 @@ func CopyOrZeroValue[T any](s *T) *T {
|
||||
}
|
||||
return cp
|
||||
}
|
||||
|
||||
// Returns a copy of an array with a unique set of elements.
|
||||
//
|
||||
// Element order is retained.
|
||||
func Uniq[T comparable](source []T) []T {
|
||||
m := orderedmap.New()
|
||||
for _, v := range source {
|
||||
m.Set(v, true)
|
||||
}
|
||||
set := make([]T, m.Len())
|
||||
i := 0
|
||||
for pair := m.Oldest(); pair != nil; pair = pair.Next() {
|
||||
set[i] = pair.Key.(T)
|
||||
i++
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
func Keys[K comparable, V any](source map[K]V) []K {
|
||||
if source == nil {
|
||||
var zero []K
|
||||
return zero
|
||||
}
|
||||
return slices.Collect(maps.Keys(source))
|
||||
}
|
||||
|
||||
func Index[K comparable, V any](source []V, indexer func(V) K) map[K]V {
|
||||
if source == nil {
|
||||
var zero map[K]V
|
||||
return zero
|
||||
}
|
||||
result := map[K]V{}
|
||||
for _, v := range source {
|
||||
k := indexer(v)
|
||||
result[k] = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func Map[E any, R any](source []E, mapper func(E) R) []R {
|
||||
if source == nil {
|
||||
var zero []R
|
||||
return zero
|
||||
}
|
||||
result := make([]R, len(source))
|
||||
for i, e := range source {
|
||||
result[i] = mapper(e)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func MapValues[K comparable, S any, T any](m map[K]S, mapper func(S) T) map[K]T {
|
||||
r := make(map[K]T, len(m))
|
||||
for k, s := range m {
|
||||
r[k] = mapper(s)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func MapValues2[K comparable, S any, T any](m map[K]S, mapper func(K, S) T) map[K]T {
|
||||
r := make(map[K]T, len(m))
|
||||
for k, s := range m {
|
||||
r[k] = mapper(k, s)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func MapKeys[S comparable, T comparable, V any](m map[S]V, mapper func(S) T) map[T]V {
|
||||
r := make(map[T]V, len(m))
|
||||
for s, v := range m {
|
||||
r[mapper(s)] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func MapKeys2[S comparable, T comparable, V any](m map[S]V, mapper func(S, V) T) map[T]V {
|
||||
r := make(map[T]V, len(m))
|
||||
for s, v := range m {
|
||||
r[mapper(s, v)] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func ToBoolMap[E comparable](source []E) map[E]bool {
|
||||
m := make(map[E]bool, len(source))
|
||||
for _, v := range source {
|
||||
m[v] = true
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func ToIntMap[E comparable](source []E) map[E]int {
|
||||
m := make(map[E]int, len(source))
|
||||
for _, v := range source {
|
||||
if e, ok := m[v]; ok {
|
||||
m[v] = e + 1
|
||||
} else {
|
||||
m[v] = 1
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func MapN[E any, R any](source []E, indexer func(E) *R) []R {
|
||||
if source == nil {
|
||||
var zero []R
|
||||
return zero
|
||||
}
|
||||
result := []R{}
|
||||
for _, e := range source {
|
||||
opt := indexer(e)
|
||||
if opt != nil {
|
||||
result = append(result, *opt)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Check whether two slices contain the same elements, ignoring order.
|
||||
func SameSlices[E comparable](x, y []E) bool {
|
||||
// https://stackoverflow.com/a/36000696
|
||||
if len(x) != len(y) {
|
||||
return false
|
||||
}
|
||||
// create a map of string -> int
|
||||
diff := make(map[E]int, len(x))
|
||||
for _, _x := range x {
|
||||
// 0 value for int is 0, so just increment a counter for the string
|
||||
diff[_x]++
|
||||
}
|
||||
for _, _y := range y {
|
||||
// If the string _y is not in diff bail out early
|
||||
if _, ok := diff[_y]; !ok {
|
||||
return false
|
||||
}
|
||||
diff[_y]--
|
||||
if diff[_y] == 0 {
|
||||
delete(diff, _y)
|
||||
}
|
||||
}
|
||||
return len(diff) == 0
|
||||
}
|
||||
|
||||
func Missing[E comparable](expected, actual []E) []E {
|
||||
missing := []E{}
|
||||
actualIndex := ToBoolMap(actual)
|
||||
for _, e := range expected {
|
||||
if _, ok := actualIndex[e]; !ok {
|
||||
missing = append(missing, e)
|
||||
}
|
||||
}
|
||||
return missing
|
||||
}
|
||||
|
||||
func FirstKey[K comparable, V any](m map[K]V) (K, bool) {
|
||||
for k := range m {
|
||||
return k, true
|
||||
}
|
||||
var zero K
|
||||
return zero, false
|
||||
}
|
||||
|
||||
func Any[E any](s []E, predicate func(E) bool) bool {
|
||||
if len(s) < 1 {
|
||||
return false
|
||||
}
|
||||
for _, e := range s {
|
||||
if predicate(e) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func AnyKey[K comparable, V any](m map[K]V, predicate func(K) bool) bool {
|
||||
if len(m) < 1 {
|
||||
return false
|
||||
}
|
||||
for k := range m {
|
||||
if predicate(k) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func AnyValue[K comparable, V any](m map[K]V, predicate func(V) bool) bool {
|
||||
if len(m) < 1 {
|
||||
return false
|
||||
}
|
||||
for _, v := range m {
|
||||
if predicate(v) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func AnyItem[K comparable, V any](m map[K]V, predicate func(K, V) bool) bool {
|
||||
if len(m) < 1 {
|
||||
return false
|
||||
}
|
||||
for k, v := range m {
|
||||
if predicate(k, v) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Concat[E any](arys ...[]E) []E {
|
||||
l := 0
|
||||
for _, ary := range arys {
|
||||
l += len(ary)
|
||||
}
|
||||
r := make([]E, l)
|
||||
|
||||
i := 0
|
||||
for _, ary := range arys {
|
||||
if ary != nil {
|
||||
i += copy(r[i:], ary)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Filter[E any](s []E, predicate func(E) bool) []E {
|
||||
r := []E{}
|
||||
for _, e := range s {
|
||||
if predicate(e) {
|
||||
r = append(r, e)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package structs
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type example struct {
|
||||
Attribute1 string
|
||||
@@ -36,3 +42,132 @@ func TestCopyOrZeroValue(t *testing.T) {
|
||||
t.Error("CopyOrZeroValue didn't correctly copy attributes")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUniqWithInts(t *testing.T) {
|
||||
tests := []struct {
|
||||
input []int
|
||||
expected []int
|
||||
}{
|
||||
{[]int{5, 1, 3, 1, 4}, []int{5, 1, 3, 4}},
|
||||
{[]int{1, 1, 1}, []int{1}},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d: testing %v", i+1, tt.input), func(t *testing.T) {
|
||||
result := Uniq(tt.input)
|
||||
assert.EqualValues(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type u struct {
|
||||
x int
|
||||
y string
|
||||
}
|
||||
|
||||
var (
|
||||
u1 = u{x: 1, y: "un"}
|
||||
u2 = u{x: 2, y: "deux"}
|
||||
u3 = u{x: 3, y: "trois"}
|
||||
)
|
||||
|
||||
func TestUniqWithStructs(t *testing.T) {
|
||||
tests := []struct {
|
||||
input []u
|
||||
expected []u
|
||||
}{
|
||||
{[]u{u3, u1, u2, u3, u2, u1}, []u{u3, u1, u2}},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d: testing %v", i+1, tt.input), func(t *testing.T) {
|
||||
result := Uniq(tt.input)
|
||||
assert.EqualValues(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeys(t *testing.T) {
|
||||
tests := []struct {
|
||||
input map[int]string
|
||||
expected []int
|
||||
}{
|
||||
{map[int]string{5: "cinq", 1: "un", 3: "trois", 4: "vier"}, []int{5, 1, 3, 4}},
|
||||
{map[int]string{1: "un"}, []int{1}},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d: testing %v", i+1, tt.input), func(t *testing.T) {
|
||||
result := Keys(tt.input)
|
||||
assert.ElementsMatch(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMissing(t *testing.T) {
|
||||
tests := []struct {
|
||||
source []string
|
||||
input []string
|
||||
expected []string
|
||||
}{
|
||||
{[]string{"a", "b", "c"}, []string{"c", "b", "a"}, []string{}},
|
||||
{[]string{"a", "b", "c"}, []string{"c", "b"}, []string{"a"}},
|
||||
{[]string{"a", "b", "c"}, []string{"c", "b", "a", "d"}, []string{}},
|
||||
{[]string{}, []string{"c", "b"}, []string{}},
|
||||
{[]string{"a", "b", "c"}, []string{}, []string{"a", "b", "c"}},
|
||||
{[]string{"a", "b", "b", "c"}, []string{"a", "b"}, []string{"c"}},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d: testing [%v] <-> [%v] == [%v]", i+1, strings.Join(tt.source, ", "), strings.Join(tt.input, ", "), strings.Join(tt.expected, ", ")), func(t *testing.T) {
|
||||
result := Missing(tt.source, tt.input)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAny(t *testing.T) {
|
||||
always := func(s string) bool { return true }
|
||||
never := func(s string) bool { return false }
|
||||
assert.True(t, Any([]string{"a", "b", "c"}, always))
|
||||
assert.False(t, Any([]string{}, always))
|
||||
assert.False(t, Any(nil, always))
|
||||
assert.False(t, Any([]string{"a", "b", "c"}, never))
|
||||
assert.False(t, Any(nil, never))
|
||||
}
|
||||
|
||||
func TestAnyKey(t *testing.T) {
|
||||
always := func(s string) bool { return true }
|
||||
never := func(s string) bool { return false }
|
||||
|
||||
assert.True(t, AnyKey(map[string]bool{"a": true, "b": false}, always))
|
||||
assert.False(t, AnyKey(map[string]bool{}, always))
|
||||
assert.False(t, AnyKey[string, bool](nil, always))
|
||||
assert.False(t, AnyKey(map[string]bool{"a": true, "b": false}, never))
|
||||
assert.False(t, AnyKey[string, bool](nil, never))
|
||||
}
|
||||
|
||||
func TestAnyValue(t *testing.T) {
|
||||
always := func(b bool) bool { return true }
|
||||
never := func(b bool) bool { return false }
|
||||
|
||||
assert.True(t, AnyValue(map[string]bool{"a": true, "b": false}, always))
|
||||
assert.False(t, AnyValue(map[string]bool{}, always))
|
||||
assert.False(t, AnyValue[string](nil, always))
|
||||
assert.False(t, AnyValue(map[string]bool{"a": true, "b": false}, never))
|
||||
assert.False(t, AnyValue[string](nil, never))
|
||||
}
|
||||
|
||||
func TestAnyItem(t *testing.T) {
|
||||
always := func(s string, b bool) bool { return true }
|
||||
never := func(s string, b bool) bool { return false }
|
||||
|
||||
assert.True(t, AnyItem(map[string]bool{"a": true, "b": false}, always))
|
||||
assert.False(t, AnyItem(map[string]bool{}, always))
|
||||
assert.False(t, AnyItem(nil, always))
|
||||
assert.False(t, AnyItem(map[string]bool{"a": true, "b": false}, never))
|
||||
assert.False(t, AnyItem(nil, never))
|
||||
}
|
||||
|
||||
func TestConcat(t *testing.T) {
|
||||
assert.Equal(t, []string{"a", "b", "c", "d", "e", "f"}, Concat([]string{"a", "b"}, []string{"c"}, []string{"d", "e", "f"}))
|
||||
assert.Equal(t, []string{"a"}, Concat([]string{"a"}))
|
||||
assert.Equal(t, []string{"a"}, Concat([]string{}, nil, []string{"a"}))
|
||||
assert.Equal(t, []string{}, Concat[string]())
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package version
|
||||
|
||||
// InitEdition exports the private edition initialization func for testing
|
||||
var InitEdition = initEdition
|
||||
@@ -1,27 +1,9 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
// Dev is used as a placeholder.
|
||||
Dev = "dev"
|
||||
// EditionDev indicates the development build channel was used to build the binary.
|
||||
EditionDev = Dev
|
||||
// EditionRolling indicates the rolling release build channel was used to build the binary.
|
||||
EditionRolling = "rolling"
|
||||
// EditionStable indicates the stable release build channel was used to build the binary.
|
||||
EditionStable = "stable"
|
||||
// EditionLTS indicates the lts release build channel was used to build the binary.
|
||||
EditionLTS = "lts"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -39,59 +21,17 @@ var (
|
||||
// Date indicates the build date.
|
||||
// This has been removed, it looks like you can only replace static strings with recent go versions
|
||||
//Date = time.Now().Format("20060102")
|
||||
Date = Dev
|
||||
Date = "dev"
|
||||
|
||||
// Legacy defines the old long 4 number OpenCloud version needed for some clients
|
||||
Legacy = "0.1.0.0"
|
||||
// LegacyString defines the old OpenCloud version needed for some clients
|
||||
LegacyString = "0.1.0"
|
||||
|
||||
// Edition describes the build channel (stable, rolling, nightly, daily, dev)
|
||||
Edition = Dev // default for self-compiled builds
|
||||
)
|
||||
|
||||
func init() { //nolint:gochecknoinits
|
||||
if err := initEdition(); err != nil {
|
||||
logger.New().Error().Err(err).Msg("falling back to dev")
|
||||
}
|
||||
}
|
||||
|
||||
func initEdition() error {
|
||||
regularEditions := []string{EditionDev, EditionRolling, EditionStable}
|
||||
versionedEditions := []string{EditionLTS}
|
||||
if !slices.ContainsFunc(slices.Concat(regularEditions, versionedEditions), func(s string) bool {
|
||||
isRegularEdition := slices.Contains(regularEditions, Edition)
|
||||
if isRegularEdition && s == Edition {
|
||||
return true
|
||||
}
|
||||
|
||||
// handle editions with a version
|
||||
editionParts := strings.Split(Edition, "-")
|
||||
if len(editionParts) != 2 { // a versioned edition channel must consist of exactly 2 parts.
|
||||
return false
|
||||
}
|
||||
|
||||
isVersionedEdition := slices.Contains(versionedEditions, editionParts[0])
|
||||
if !isVersionedEdition { // not all channels can contain version information
|
||||
return false
|
||||
}
|
||||
|
||||
_, err := semver.NewVersion(editionParts[1])
|
||||
return err == nil
|
||||
}) {
|
||||
defer func() {
|
||||
Edition = Dev
|
||||
}()
|
||||
|
||||
return fmt.Errorf(`unknown edition channel '%s'`, Edition)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compiled returns the compile time of this service.
|
||||
func Compiled() time.Time {
|
||||
if Date == Dev {
|
||||
if Date == "dev" {
|
||||
return time.Now()
|
||||
}
|
||||
t, _ := time.Parse("20060102", Date)
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package version_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/version"
|
||||
)
|
||||
|
||||
func TestChannel(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
got string
|
||||
valid bool
|
||||
}{
|
||||
"no channel, defaults to dev": {
|
||||
got: "",
|
||||
valid: false,
|
||||
},
|
||||
"dev channel": {
|
||||
got: version.EditionDev,
|
||||
valid: true,
|
||||
},
|
||||
"rolling channel": {
|
||||
got: version.EditionRolling,
|
||||
valid: true,
|
||||
},
|
||||
"stable channel": {
|
||||
got: version.EditionStable,
|
||||
valid: true,
|
||||
},
|
||||
"lts channel without version": {
|
||||
got: version.EditionLTS,
|
||||
valid: false,
|
||||
},
|
||||
"lts-1.0.0 channel": {
|
||||
got: fmt.Sprintf("%s-1", version.EditionLTS),
|
||||
valid: true,
|
||||
},
|
||||
"lts-one invalid version": {
|
||||
got: fmt.Sprintf("%s-one", version.EditionLTS),
|
||||
valid: false,
|
||||
},
|
||||
"known channel with version": {
|
||||
got: fmt.Sprintf("%s-1", version.EditionStable),
|
||||
valid: false,
|
||||
},
|
||||
"unknown channel": {
|
||||
got: "foo",
|
||||
valid: false,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
version.Edition = test.got
|
||||
|
||||
switch err := version.InitEdition(); {
|
||||
case err != nil && !test.valid && version.Edition != version.Dev: // if a given edition is unknown, the value is always dev
|
||||
fallthrough
|
||||
case test.valid != (err == nil):
|
||||
t.Fatalf("invalid edition: %s", version.Edition)
|
||||
case !test.valid && !strings.Contains(err.Error(), "'"+test.got+"'"):
|
||||
t.Fatalf("no mention of invalid edition '%s' in error: %s", test.got, err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
19
services/activitylog/cmd/activitylog/main.go
Normal file
19
services/activitylog/cmd/activitylog/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/command"
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,16 @@ package command
|
||||
|
||||
import (
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/config"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Health is the entrypoint for the health command.
|
||||
func Health(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "health",
|
||||
Short: "Check health status",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// not implemented
|
||||
func Health(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "health",
|
||||
Usage: "Check health status",
|
||||
Action: func(c *cli.Context) error {
|
||||
// Not implemented
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/clihelper"
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/config"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// GetCommands provides all commands for this service
|
||||
func GetCommands(cfg *config.Config) []*cobra.Command {
|
||||
return []*cobra.Command{
|
||||
func GetCommands(cfg *config.Config) cli.Commands {
|
||||
return []*cli.Command{
|
||||
// start this service
|
||||
Server(cfg),
|
||||
|
||||
@@ -24,11 +24,11 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
|
||||
|
||||
// Execute is the entry point for the activitylog command.
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := clihelper.DefaultApp(&cobra.Command{
|
||||
Use: "activitylog",
|
||||
Short: "starts activitylog service",
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "activitylog",
|
||||
Usage: "starts activitylog service",
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
app.AddCommand(GetCommands(cfg)...)
|
||||
app.SetArgs(os.Args[1:])
|
||||
return app.ExecuteContext(cfg.Context)
|
||||
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/events/stream"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/store"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
|
||||
@@ -47,23 +47,24 @@ var _registeredEvents = []events.Unmarshaller{
|
||||
}
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
func Server(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "server",
|
||||
Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
func Server(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "server",
|
||||
Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
Category: "server",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
|
||||
tracerProvider, err := tracing.GetTraceProvider(c.Context, cfg.Commons.TracesExporter, cfg.Service.Name)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to initialize tracer")
|
||||
return err
|
||||
}
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := context.WithCancel(cmd.Context())
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
mtrcs := metrics.New()
|
||||
mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1)
|
||||
|
||||
@@ -2,15 +2,16 @@ package command
|
||||
|
||||
import (
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/config"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Version prints the service versions of all running instances.
|
||||
func Version(cfg *config.Config) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version of this binary and the running service instances",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
func Version(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print the version of this binary and the running service instances",
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
// not implemented
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -11,8 +11,7 @@ import (
|
||||
"github.com/opencloud-eu/opencloud/services/activitylog/pkg/metrics"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/events"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go-micro.dev/v4/store"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
@@ -26,7 +25,7 @@ type Options struct {
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []pflag.Flag
|
||||
Flags []cli.Flag
|
||||
Namespace string
|
||||
Store store.Store
|
||||
Stream events.Stream
|
||||
@@ -77,9 +76,9 @@ func Metrics(val *metrics.Metrics) Option {
|
||||
}
|
||||
|
||||
// Flags provides a function to set the flags option.
|
||||
func Flags(flags ...pflag.Flag) Option {
|
||||
func Flags(val []cli.Flag) Option {
|
||||
return func(o *Options) {
|
||||
o.Flags = append(o.Flags, flags...)
|
||||
o.Flags = append(o.Flags, val...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-20 00:05+0000\n"
|
||||
"POT-Creation-Date: 2025-11-30 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: Ivan Fustero, 2025\n"
|
||||
"Language-Team: Catalan (https://app.transifex.com/opencloud-eu/teams/204053/ca/)\n"
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-20 00:05+0000\n"
|
||||
"POT-Creation-Date: 2025-11-30 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: Jörn Friedrich Dreyer <jfd@butonic.de>, 2025\n"
|
||||
"Language-Team: German (https://app.transifex.com/opencloud-eu/teams/204053/de/)\n"
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-20 00:05+0000\n"
|
||||
"POT-Creation-Date: 2025-11-30 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: Elías Martín, 2025\n"
|
||||
"Language-Team: Spanish (https://app.transifex.com/opencloud-eu/teams/204053/es/)\n"
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-16 00:02+0000\n"
|
||||
"POT-Creation-Date: 2025-11-26 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: Jiri Grönroos <jiri.gronroos@iki.fi>, 2025\n"
|
||||
"Language-Team: Finnish (https://app.transifex.com/opencloud-eu/teams/204053/fi/)\n"
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-20 00:05+0000\n"
|
||||
"POT-Creation-Date: 2025-11-30 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: eric_G <junk.eg@free.fr>, 2025\n"
|
||||
"Language-Team: French (https://app.transifex.com/opencloud-eu/teams/204053/fr/)\n"
|
||||
|
||||
@@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: EMAIL\n"
|
||||
"POT-Creation-Date: 2025-12-20 00:05+0000\n"
|
||||
"POT-Creation-Date: 2025-11-30 00:02+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 10:17+0000\n"
|
||||
"Last-Translator: Simone Broglia, 2025\n"
|
||||
"Language-Team: Italian (https://app.transifex.com/opencloud-eu/teams/204053/it/)\n"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user