Skip to content

Commit

Permalink
Merge branch 'master' into node20
Browse files Browse the repository at this point in the history
  • Loading branch information
sblaisot committed Jan 5, 2024
2 parents d4bf075 + f4ced11 commit 9890e17
Show file tree
Hide file tree
Showing 49 changed files with 999 additions and 261 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
# impact debian packaging files, only sblaisot and not the global
# owner(s) will be requested for a review.
debian/* @sblaisot
scripts/docker/* @sblaisot
scripts/packaging/* @sblaisot
2 changes: 1 addition & 1 deletion .github/workflows/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
token: ${{ secrets.COZYBOT_ACCESS_TOKEN }}
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
token: ${{ secrets.COZYBOT_ACCESS_TOKEN }}
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: lint
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
needs: create_release
steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --force-yes couchdb=3.3.2*
echo "COZY_COUCHDB_URL=http:https://admin:[email protected]:5984/" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- name: Install Ruby
Expand Down
1 change: 1 addition & 0 deletions assets/templates/share_by_link_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h1 class="h4 h2-md mb-3 text-center">{{t "Share by link Password Title"}}</h1>
</main>
</form>
<script src="{{asset .Domain "/scripts/cirrus.js"}}"></script>
<script src="{{asset .Domain "/scripts/password-visibility.js"}}"></script>
<script src="{{asset .Domain "/scripts/share-by-link.js"}}"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions client/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Instance struct {
UUID string `json:"uuid,omitempty"`
OIDCID string `json:"oidc_id,omitempty"`
ContextName string `json:"context,omitempty"`
Sponsorships []string `json:"sponsorships,omitempty"`
TOSSigned string `json:"tos,omitempty"`
TOSLatest string `json:"tos_latest,omitempty"`
AuthMode int `json:"auth_mode,omitempty"`
Expand Down Expand Up @@ -65,6 +66,7 @@ type InstanceOptions struct {
TOSLatest string
Timezone string
ContextName string
Sponsorships []string
Email string
PublicName string
Settings string
Expand Down Expand Up @@ -164,6 +166,9 @@ func (ac *AdminClient) CreateInstance(opts *InstanceOptions) (*Instance, error)
if opts.DomainAliases != nil {
q.Add("DomainAliases", strings.Join(opts.DomainAliases, ","))
}
if opts.Sponsorships != nil {
q.Add("Sponsorships", strings.Join(opts.Sponsorships, ","))
}
if opts.MagicLink != nil && *opts.MagicLink {
q.Add("MagicLink", "true")
}
Expand Down Expand Up @@ -237,6 +242,9 @@ func (ac *AdminClient) ModifyInstance(opts *InstanceOptions) (*Instance, error)
if opts.DomainAliases != nil {
q.Add("DomainAliases", strings.Join(opts.DomainAliases, ","))
}
if opts.Sponsorships != nil {
q.Add("Sponsorships", strings.Join(opts.Sponsorships, ","))
}
if opts.MagicLink != nil {
q.Add("MagicLink", strconv.FormatBool(*opts.MagicLink))
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var flagTOSSigned string
var flagTOS string
var flagTOSLatest string
var flagContextName string
var flagSponsorships []string
var flagOnboardingFinished bool
var flagTTL time.Duration
var flagExpire time.Duration
Expand Down Expand Up @@ -188,6 +189,7 @@ be used as the error message.
TOSSigned: flagTOSSigned,
Timezone: flagTimezone,
ContextName: flagContextName,
Sponsorships: flagSponsorships,
Email: flagEmail,
PublicName: flagPublicName,
Settings: flagSettings,
Expand Down Expand Up @@ -276,6 +278,7 @@ settings for a specified domain.
TOSLatest: flagTOSLatest,
Timezone: flagTimezone,
ContextName: flagContextName,
Sponsorships: flagSponsorships,
Email: flagEmail,
PublicName: flagPublicName,
Settings: flagSettings,
Expand Down Expand Up @@ -1085,6 +1088,7 @@ func init() {
addInstanceCmd.Flags().StringVar(&flagTOS, "tos", "", "The TOS version signed")
addInstanceCmd.Flags().StringVar(&flagTimezone, "tz", "", "The timezone for the user")
addInstanceCmd.Flags().StringVar(&flagContextName, "context-name", "", "Context name of the instance")
addInstanceCmd.Flags().StringSliceVar(&flagSponsorships, "sponsorships", nil, "Sponsorships of the instance (comma separated list)")
addInstanceCmd.Flags().StringVar(&flagEmail, "email", "", "The email of the owner")
addInstanceCmd.Flags().StringVar(&flagPublicName, "public-name", "", "The public name of the owner")
addInstanceCmd.Flags().StringVar(&flagSettings, "settings", "", "A list of settings (eg context:foo,offer:premium)")
Expand All @@ -1105,6 +1109,7 @@ func init() {
modifyInstanceCmd.Flags().StringVar(&flagTOSLatest, "tos-latest", "", "Update the latest TOS version")
modifyInstanceCmd.Flags().StringVar(&flagTimezone, "tz", "", "New timezone")
modifyInstanceCmd.Flags().StringVar(&flagContextName, "context-name", "", "New context name")
modifyInstanceCmd.Flags().StringSliceVar(&flagSponsorships, "sponsorships", nil, "Sponsorships of the instance (comma separated list)")
modifyInstanceCmd.Flags().StringVar(&flagEmail, "email", "", "New email")
modifyInstanceCmd.Flags().StringVar(&flagPublicName, "public-name", "", "New public name")
modifyInstanceCmd.Flags().StringVar(&flagSettings, "settings", "", "New list of settings (eg offer:premium)")
Expand Down
2 changes: 1 addition & 1 deletion cozy.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ contexts:
# Change the limit on the number of members for a sharing
max_members_per_sharing: 50
# Use a different wizard for moving a Cozy
move_url: htts:https://move.cozy.beta/
move_url: https:https://move.cozy.beta/
# Feature flags
features:
- hide_konnector_errors
Expand Down
64 changes: 64 additions & 0 deletions docs/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,70 @@ Content-Type: application/zip
Content-Disposition: attachment; filename="alice.cozy.localhost - part001.zip"
```

### POST /instances/:domain/notifications

This endpoint allows to send a notification via the notification center. Both
the notification declaration and its properties need to be passed in the body.
These notifications cannot use templates defined in cozy-stack though so their
e-mail content must be provided directly (at least in HTML).

When the request is successful, the generated notification object is returned.

```http
POST /instances/alice.cozy.localhost/notifications HTTP/1.1
Authorization: Bearer ...
Content-Type: application/json
```

```json
{
"notification": {
"category": "account-balance",
"category_id": "my-bank",
"title": "Your account balance is not OK",
"message": "Warning: we have detected a negative balance in your my-bank",
"priority": "high",
"state": "-1",
"preferred_channels": ["mobile"],
"content": "Hello,\r\nWe have detected a negative balance in your my-bank account.",
"content_html": "<html>\r\n\t<body>\r\n\t<p>Hello,<br/>We have detected a negative balance in your my-bank account.</p>\r\n\t</body>\r\n\t</html>"
},
"properties": {
"description": "Alert the user when its account balance is negative",
"collapsible": true,
"multiple": true,
"stateful": true,
"default_priority": "high"
}
}
```

#### Response

```http
HTTP/1.1 201 Created
Content-Type: application/json
```

```json
{
"_id": "c57a548c-7602-11e7-933b-6f27603d27da",
"_rev": "1-1f2903f9a867",
"source_id": "cozy/cli//account-balance/my-bank",
"originator": "cli",
"category": "account-balance",
"category_id": "my-bank",
"created_at": "2024-01-04T15:23:01.832Z",
"last_sent": "2024-01-04T15:23:01.832Z",
"title": "Your account balance is not OK",
"message": "Warning: we have detected a negative balance in your my-bank",
"priority": "high",
"state": "-1",
"content": "Hello,\r\nWe have detected a negative balance in your my-bank account.",
"contentHTML": "<html>\r\n\t<body>\r\n\t<p>Hello,<br/>We have detected a negative balance in your my-bank account.</p>\r\n\t</body>\r\n\t</html>"
}
```

## Contexts

### GET /instances/contexts
Expand Down
1 change: 1 addition & 0 deletions docs/cli/cozy-stack_instances_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $ cozy-stack instances add --passphrase cozy --apps drive,photos,settings,home,s
--passphrase string Register the instance with this passphrase (useful for tests)
--public-name string The public name of the owner
--settings string A list of settings (eg context:foo,offer:premium)
--sponsorships strings Sponsorships of the instance (comma separated list)
--swift-layout int Specify the layout to use for Swift (from 0 for layout V1 to 2 for layout V3, -1 means the default) (default -1)
--tos string The TOS version signed
--trace Show where time is spent
Expand Down
1 change: 1 addition & 0 deletions docs/cli/cozy-stack_instances_modify.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cozy-stack instances modify <domain> [flags]
--onboarding-finished Force the finishing of the onboarding
--public-name string New public name
--settings string New list of settings (eg offer:premium)
--sponsorships strings Sponsorships of the instance (comma separated list)
--tos string Update the TOS version signed
--tos-latest string Update the latest TOS version
--tz string New timezone
Expand Down
2 changes: 1 addition & 1 deletion docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This endpoint can be used to push a new notification to the user.
Notifications fields are:

- `category` (string): name of the notification category
- `category_id` (string): category name if the category is multiple
- `category_id` (string): name of the notification sub-category if relevant (optional)
- `title` (string): title of the notification
- `message` (string): message of of the notification (optional)
- `priority` (string): priority of the notification (`high` or `normal`), sent
Expand Down
3 changes: 2 additions & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ Cookie: sessionid=xxxx
"public_name": "Alice Martin",
"auth_mode": "basic",
"default_redirection": "drive/#/folder",
"context": "dev"
"context": "dev",
"sponsorships": ["springfield"]
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,27 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/justincampbell/bigduration v0.0.0-20160531141349-e45bf03c0666
github.com/labstack/echo/v4 v4.11.3
github.com/labstack/echo/v4 v4.11.4
github.com/leonelquinteros/gotext v1.5.2
github.com/mitchellh/mapstructure v1.5.0
github.com/mssola/user_agent v0.6.0
github.com/ncw/swift/v2 v2.0.2
github.com/nightlyone/lockfile v1.0.0
github.com/ohler55/ojg v1.20.3
github.com/oschwald/maxminddb-golang v1.12.0
github.com/pquerna/otp v1.4.0
github.com/prometheus/client_golang v1.17.0
github.com/redis/go-redis/v9 v9.3.0
github.com/prometheus/client_golang v1.18.0
github.com/redis/go-redis/v9 v9.3.1
github.com/robfig/cron/v3 v3.0.1
github.com/sideshow/apns2 v0.23.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.1
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/ugorji/go/codec v1.2.12
github.com/yuin/goldmark v1.6.0
golang.org/x/crypto v0.16.0
golang.org/x/crypto v0.17.0
golang.org/x/image v0.14.0
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.15.0
Expand Down Expand Up @@ -77,20 +78,19 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jonas-p/go-shp v0.1.1 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.18.1 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand Down
Loading

0 comments on commit 9890e17

Please sign in to comment.