Skip to content

Commit c92e559

Browse files
committed
Split the path for accepting a sharing
When a user has received an email for a sharing, they can go to the preview page. From here, there are two possibilities for accepting the sharing: just creating a shortcut, or the full synchronization. Before this commit, the user was first asked their Cozy URL, and on the OAuth authorize page, they have a checkbox for the synchronize option. Now, the choice is made on the preview page (Drive will add a `shortcut=true` parameter in the query string on the `GET /sharings/:id/discovery` endpoint if needed). And if it is just a shortcut, we will skip the OAuth authorize page.
1 parent 678a744 commit c92e559

14 files changed

Lines changed: 1032 additions & 1013 deletions

File tree

assets/locales/de.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,9 @@ msgstr "Die Cozy URL ist nicht deine E-Mail-Adresse"
826826
msgid "Sharing Discovery Submit"
827827
msgstr "In mein Cozy synchronisieren"
828828

829+
msgid "Sharing Discovery Shortcut Submit"
830+
msgstr "In mein Cozy synchronisieren"
831+
829832
msgid "Sharing No Cozy"
830833
msgstr "Hast du noch kein Cozy?"
831834

assets/locales/en.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,9 @@ msgstr "The Cozy URL is not your email address."
11391139
msgid "Sharing Discovery Submit"
11401140
msgstr "Synchronize into my Cozy"
11411141

1142+
msgid "Sharing Discovery Shortcut Submit"
1143+
msgstr "Add to my Cozy"
1144+
11421145
msgid "Sharing No Cozy"
11431146
msgstr "Don't have a Cozy yet?"
11441147

assets/locales/es.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ msgstr "La URL de su Cozy no es la dirección de su correo electrónico"
840840
msgid "Sharing Discovery Submit"
841841
msgstr "Sincronizar en mi Cozy"
842842

843+
msgid "Sharing Discovery Shortcut Submit"
844+
msgstr "Sincronizar en mi Cozy"
845+
843846
msgid "Sharing No Cozy"
844847
msgstr "¿Todavía no tiene una Cozy?"
845848

assets/locales/fr.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,9 @@ msgstr "L'URL de votre Cozy n'est pas votre adresse email."
12441244
msgid "Sharing Discovery Submit"
12451245
msgstr "Synchroniser dans mon Cozy"
12461246

1247+
msgid "Sharing Discovery Shortcut Submit"
1248+
msgstr "Ajouter à mon Cozy"
1249+
12471250
msgid "Sharing No Cozy"
12481251
msgstr "Pas encore de Cozy ?"
12491252

assets/locales/ja.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ msgstr "Cozy の URL はメールアドレスではありません。"
648648
msgid "Sharing Discovery Submit"
649649
msgstr "送信"
650650

651+
msgid "Sharing Discovery Shortcut Submit"
652+
msgstr "送信"
653+
651654
msgid "Sharing No Cozy"
652655
msgstr "まだ Cozy をお持ちではありませんか?"
653656

assets/locales/nl_NL.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ msgstr "De Cozy-url is niet je e-mailadres."
10241024
msgid "Sharing Discovery Submit"
10251025
msgstr "Synchroniseren naar mijn Cozy"
10261026

1027+
msgid "Sharing Discovery Shortcut Submit"
1028+
msgstr "Synchroniseren naar mijn Cozy"
1029+
10271030
msgid "Sharing No Cozy"
10281031
msgstr "Heb je nog geen Cozy?"
10291032

assets/templates/authorize_sharing.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ <h1 class="h4 h2-md mb-4 text-center">{{t "Authorize Sharing Title Add"}}</h1>
4646
</p>
4747
</div>
4848

49-
{{if .HasShortcut}}
50-
<input type="hidden" name="synchronize" value="true" />
51-
{{else}}
52-
<div class="form-check mb-2">
53-
<input class="form-check-input" type="checkbox" id="synchronize" name="synchronize" checked />
54-
<label class="form-check-label" for="synchronize">
55-
{{t "Authorize Sharing Synchronize label"}}
56-
</label>
57-
</div>
58-
{{end}}
5949
<p class="{{if not .HasShortcut}}ps-4{{else}}text-center{{end}} caption text-muted mb-2">
6050
{{t "Authorize Sharing Description start" .SharerName .TargetType}}
6151
</p>

assets/templates/sharing_discovery.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<form method="POST" action="/sharings/{{.SharingID}}/discovery" class="d-contents">
1616
<input type="hidden" name="state" value="{{.State}}" />
1717
<input type="hidden" name="sharecode" value="{{.ShareCode}}" />
18+
<input type="hidden" name="shortcut" value="{{.Shortcut}}" />
1819
<main class="wrapper">
1920
<header class="wrapper-top">
2021
<a href="https://cozy.io/" class="btn p-2 d-sm-none">
@@ -55,7 +56,11 @@ <h1 class="h4 h2-md mb-2 text-center">{{t "Sharing Connect to Cozy"}}</h1>
5556
</a>
5657
</p>
5758
<button id="login-submit" class="btn btn-primary btn-md-lg w-100 mb-3" type="submit">
59+
{{if .Shortcut}}
60+
{{t "Sharing Discovery Shortcut Submit"}}
61+
{{else}}
5862
{{t "Sharing Discovery Submit"}}
63+
{{end}}
5964
</button>
6065
</footer>
6166
</main>

docs/sharing.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,15 @@ just have to click OK).
184184

185185
#### Query-String
186186

187-
| Parameter | Description |
188-
| --------- | ---------------------------------- |
189-
| state | a code that identify the recipient |
187+
| Parameter | Description |
188+
| --------- | ----------------------------------------------------------------------------------------- |
189+
| state | a code that identify the recipient |
190+
| shortcut | true means that accepting the sharing will just create a shortcut on the recipient's Cozy |
190191

191192
#### Example
192193

193194
```http
194-
GET /sharings/ce8835a061d0ef68947afe69a0046722/discovery?state=eiJ3iepoaihohz1Y HTTP/1.1
195+
GET /sharings/ce8835a061d0ef68947afe69a0046722/discovery?state=eiJ3iepoaihohz1Y&shortcut=true HTTP/1.1
195196
Host: alice.example.net
196197
```
197198

@@ -206,10 +207,11 @@ This route exists in two versions, the version is selected by the HTTP header
206207

207208
#### Classical (`x-www-form-urlencoded`)
208209

209-
| Parameter | Description |
210-
| --------- | ------------------------------------- |
211-
| state | a code that identify the recipient |
212-
| url | the URL of the Cozy for the recipient |
210+
| Parameter | Description |
211+
| --------- | ----------------------------------------------------------------------------------------- |
212+
| state | a code that identify the recipient |
213+
| url | the URL of the Cozy for the recipient |
214+
| shortcut | true means that accepting the sharing will just create a shortcut on the recipient's Cozy |
213215

214216
##### Example
215217

@@ -1207,8 +1209,8 @@ HTTP/1.1 204 No Content
12071209
### DELETE /sharings/:sharing-id/recipients/:index
12081210

12091211
This route can be only be called on the cozy instance of the sharer to revoke
1210-
only one recipient of the sharing. The parameter is the index of this recipient
1211-
in the `members` array of the sharing.
1212+
only one recipient of the sharing. The parameter is the index of this recipient
1213+
in the `members` array of the sharing.
12121214
The status for this member will be set to `revoked`, its cozy will be informed of the
12131215
revokation, and the credentials for this cozy will be deleted.
12141216

model/sharing/member.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,17 @@ func (s *Sharing) AddDelegatedContact(inst *instance.Instance, m Member) (string
452452
// DelegateDiscovery delegates the POST discovery when a recipient has invited
453453
// another person to a sharing, and this person accepts the sharing on the
454454
// recipient cozy. The calls is delegated to the owner cozy.
455-
func (s *Sharing) DelegateDiscovery(inst *instance.Instance, state, cozyURL string) (string, error) {
455+
func (s *Sharing) DelegateDiscovery(inst *instance.Instance, state, cozyURL, shortcut string) (string, error) {
456456
u, err := url.Parse(s.Members[0].Instance)
457457
if err != nil {
458458
return "", err
459459
}
460460
v := url.Values{}
461461
v.Add("state", state)
462462
v.Add("url", cozyURL)
463+
if shortcut != "" {
464+
v.Add("shortcut", shortcut)
465+
}
463466
body := []byte(v.Encode())
464467
if len(s.Credentials) == 0 {
465468
return "", ErrInvalidSharing

0 commit comments

Comments
 (0)