M db.go => db.go +1 -0
@@ 17,6 17,7 @@ var ErrNotFound = fmt.Errorf("resource not found in DB")
type Installation struct {
ID int64 `json:"-"`
Owner string `json:"owner"`
+ Org string `json:"org,omitempty"`
CreatedAt time.Time `json:"created_at"`
SrhtToken string `json:"srht_token,omitempty"`
}
M main.go => main.go +18 -8
@@ 207,16 207,25 @@ func main() {
return
}
+ var installSettingsURL string
+ if installation != nil {
+ if installation.Org != "" {
+ installSettingsURL = fmt.Sprintf("https://github.com/organizations/%v/settings/installations/%v", installation.Org, id)
+ } else {
+ installSettingsURL = fmt.Sprintf("https://github.com/settings/installations/%v", id)
+ }
+ }
+
data := struct {
- Pending bool
- Done bool
- SrhtGrants string
- InstallationID int64
+ Pending bool
+ Done bool
+ SrhtGrants string
+ InstallSettingsURL string
}{
- Pending: installation == nil,
- Done: installation != nil && installation.SrhtToken != "",
- SrhtGrants: srhtGrants,
- InstallationID: id,
+ Pending: installation == nil,
+ Done: installation != nil && installation.SrhtToken != "",
+ SrhtGrants: srhtGrants,
+ InstallSettingsURL: installSettingsURL,
}
if err := tpl.ExecuteTemplate(w, "post-install.html", &data); err != nil {
panic(err)
@@ 249,6 258,7 @@ func main() {
ID: *event.Installation.ID,
CreatedAt: time.Now(),
Owner: event.Sender.GetLogin(),
+ Org: event.GetOrg().GetLogin(),
})
case "deleted":
err = db.DeleteInstallation(*event.Installation.ID)
M templates/post-install.html => templates/post-install.html +1 -1
@@ 10,7 10,7 @@
{{ else if .Done }}
<p>Installation complete!</p>
<p>
- To manage the installation, <a href="https://github.com/settings/installations/{{ .InstallationID }}">head over to GitHub settings</a>.
+ To manage the installation, <a href="{{ .InstallSettingsURL }}">head over to GitHub settings</a>.
</p>
{{ else }}
<p>