3
0

Added contact to nodes

This commit is contained in:
Peter Grlica 2020-12-08 20:32:52 +01:00
parent 67b95cd0ce
commit 61782cf08d
8 changed files with 55 additions and 0 deletions

View File

@ -64,6 +64,10 @@ endpoints:
type: string
required: false
title: Name for this node
- name: contact
type: string
required: false
title: Contact email
- name: pairingURI
type: string
required: false
@ -93,6 +97,10 @@ endpoints:
type: string
required: false
title: Name for this node
- name: contact
type: string
required: false
title: Contact email
- name: baseURL
type: string
required: false

View File

@ -65,6 +65,7 @@ func (ctrl Node) Create(ctx context.Context, r *request.NodeCreate) (interface{}
n := &types.Node{
BaseURL: r.BaseURL,
Name: r.Name,
Contact: r.Contact,
}
n, err := ctrl.svcNode.Create(ctx, n)
@ -82,6 +83,7 @@ func (ctrl Node) Update(ctx context.Context, r *request.NodeUpdate) (interface{}
ID: r.NodeID,
Name: r.Name,
BaseURL: r.BaseURL,
Contact: r.Contact,
})
return ctrl.makePayload(ctx, n, err)

View File

@ -52,6 +52,11 @@ type (
// Name for this node
Name string
// Contact POST parameter
//
// Contact email
Contact string
// PairingURI POST parameter
//
// Pairing URI
@ -83,6 +88,11 @@ type (
// Name for this node
Name string
// Contact POST parameter
//
// Contact email
Contact string
// BaseURL POST parameter
//
// Federation API base URL
@ -197,6 +207,7 @@ func (r NodeCreate) Auditable() map[string]interface{} {
return map[string]interface{}{
"baseURL": r.BaseURL,
"name": r.Name,
"contact": r.Contact,
"pairingURI": r.PairingURI,
}
}
@ -211,6 +222,11 @@ func (r NodeCreate) GetName() string {
return r.Name
}
// Auditable returns all auditable/loggable parameters
func (r NodeCreate) GetContact() string {
return r.Contact
}
// Auditable returns all auditable/loggable parameters
func (r NodeCreate) GetPairingURI() string {
return r.PairingURI
@ -250,6 +266,13 @@ func (r *NodeCreate) Fill(req *http.Request) (err error) {
}
}
if val, ok := req.Form["contact"]; ok && len(val) > 0 {
r.Contact, err = val[0], nil
if err != nil {
return err
}
}
if val, ok := req.Form["pairingURI"]; ok && len(val) > 0 {
r.PairingURI, err = val[0], nil
if err != nil {
@ -361,6 +384,7 @@ func (r NodeUpdate) Auditable() map[string]interface{} {
return map[string]interface{}{
"nodeID": r.NodeID,
"name": r.Name,
"contact": r.Contact,
"baseURL": r.BaseURL,
}
}
@ -375,6 +399,11 @@ func (r NodeUpdate) GetName() string {
return r.Name
}
// Auditable returns all auditable/loggable parameters
func (r NodeUpdate) GetContact() string {
return r.Contact
}
// Auditable returns all auditable/loggable parameters
func (r NodeUpdate) GetBaseURL() string {
return r.BaseURL
@ -407,6 +436,13 @@ func (r *NodeUpdate) Fill(req *http.Request) (err error) {
}
}
if val, ok := req.Form["contact"]; ok && len(val) > 0 {
r.Contact, err = val[0], nil
if err != nil {
return err
}
}
if val, ok := req.Form["baseURL"]; ok && len(val) > 0 {
r.BaseURL, err = val[0], nil
if err != nil {

View File

@ -114,6 +114,7 @@ func (svc node) Create(ctx context.Context, new *types.Node) (*types.Node, error
ID: nextID(),
Name: new.Name,
BaseURL: new.BaseURL,
Contact: new.Contact,
Status: types.NodeStatusPending,
CreatedAt: *now(),
}
@ -235,6 +236,7 @@ func (svc node) Update(ctx context.Context, upd *types.Node) (*types.Node, error
return svc.updater(ctx, upd.ID, NodeActionUpdate, func(ctx context.Context, n *types.Node) error {
n.Name = upd.Name
n.BaseURL = upd.BaseURL
n.Contact = upd.Contact
n.UpdatedBy = auth.GetIdentityFromContext(ctx).Identity()
n.UpdatedAt = now()

View File

@ -22,6 +22,8 @@ type (
// Base URL of the remote server
BaseURL string `json:"baseURL"`
Contact string `json:"contact"`
// Node ID on the remote server that points back to us
SharedNodeID uint64 `json:"sharedNodeID,string"`

View File

@ -10,6 +10,7 @@ fields:
- { field: SharedNodeID }
- { field: BaseURL }
- { field: Status }
- { field: Contact }
- { field: PairToken }
- { field: AuthToken }
- { field: CreatedBy }

View File

@ -265,6 +265,7 @@ func (s Store) internalFederationNodeRowScanner(row rowScanner) (res *types.Node
&res.SharedNodeID,
&res.BaseURL,
&res.Status,
&res.Contact,
&res.PairToken,
&res.AuthToken,
&res.CreatedBy,
@ -317,6 +318,7 @@ func (Store) federationNodeColumns(aa ...string) []string {
alias + "shared_node_id",
alias + "base_url",
alias + "status",
alias + "contact",
alias + "pair_token",
alias + "auth_token",
alias + "created_by",
@ -341,6 +343,7 @@ func (s Store) internalFederationNodeEncoder(res *types.Node) store.Payload {
"shared_node_id": res.SharedNodeID,
"base_url": res.BaseURL,
"status": res.Status,
"contact": res.Contact,
"pair_token": res.PairToken,
"auth_token": res.AuthToken,
"created_by": res.CreatedBy,

View File

@ -541,6 +541,7 @@ func (Schema) FederationNodes() *Table {
ColumnDef("name", ColumnTypeText),
ColumnDef("base_url", ColumnTypeText),
ColumnDef("status", ColumnTypeText),
ColumnDef("contact", ColumnTypeVarchar, ColumnTypeLength(emailLength)),
ColumnDef("pair_token", ColumnTypeText),
ColumnDef("auth_token", ColumnTypeText),