From c8295ca70e3425180fec6796a02ca40693e7bb4d Mon Sep 17 00:00:00 2001 From: stremovsky Date: Thu, 12 Dec 2019 20:57:53 +0200 Subject: [PATCH] use mode instead of type --- API.md | 5 ++++- src/consent_db.go | 6 +++--- ui/site/user-data-processing.html | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/API.md b/API.md index 5f88599..64942f2 100644 --- a/API.md +++ b/API.md @@ -275,7 +275,10 @@ Fetch by user token: curl --header "X-Bunker-Token: $XTOKEN" -XGET \ https://localhost:3000/v1/consent/email/test@paranoidguy.com {"status":"ok","total":2,"rows":[ - {"brief":"send-email-mailgun-on-login","message":"send-email-mailgun-on-login","status":"accept","token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","type":"email","when":1576154130,"who":"test@paranoidguy.com"},{"brief":"send-sms-twilio-on-login","message":"send-sms-twilio-on-login","status":"accept","token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","type":"phone","when":1576174683,"who":"4444"}]} + {"brief":"send-email-mailgun-on-login","message":"send-email-mailgun-on-login","status":"accept", + "token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","mode":"email","when":1576154130,"who":"test@paranoidguy.com"}, + {"brief":"send-sms-twilio-on-login","message":"send-sms-twilio-on-login","status":"accept", + "token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","mode":"phone","when":1576174683,"who":"4444"}]} ``` ### List granted diff --git a/src/consent_db.go b/src/consent_db.go index b6eee13..698ac72 100644 --- a/src/consent_db.go +++ b/src/consent_db.go @@ -13,14 +13,14 @@ import ( type consentEvent struct { When int32 `json:"when,omitempty" structs:"when"` Who string `json:"who,omitempty" structs:"who"` - Type string `json:"type,omitempty" structs:"type"` + Mode string `json:"mode,omitempty" structs:"mode"` Token string `json:"token,omitempty" structs:"token"` Brief string `json:"brief,omitempty" structs:"brief"` Message string `json:"message,omitempty" structs:"message"` Status string `json:"status,omitempty" structs:"status"` } -func (dbobj dbcon) createConsentRecord(userTOKEN string, usertype string, usercode string, brief string, message string, status string) { +func (dbobj dbcon) createConsentRecord(userTOKEN string, mode string, usercode string, brief string, message string, status string) { now := int32(time.Now().Unix()) // brief can not be too long, may be hash it ? if len(brief) > 64 { @@ -47,7 +47,7 @@ func (dbobj dbcon) createConsentRecord(userTOKEN string, usertype string, userco When: now, Who: usercode, Token: userTOKEN, - Type: usertype, + Mode: mode, Brief: brief, Message: message, Status: status, diff --git a/ui/site/user-data-processing.html b/ui/site/user-data-processing.html index be6c482..1162f48 100644 --- a/ui/site/user-data-processing.html +++ b/ui/site/user-data-processing.html @@ -150,7 +150,7 @@ } var start = '
'; var d = '
When: ' + dateFormat(row.when) + '
' - var identity = '
Identity: ' + row.who + ' (' + row.type + ')
' + msg + '
' + var identity = '
Identity: ' + row.who + ' (' + row.mode + ')
' + msg + '
' var cancel = "cancel"; var accept = "accept"; var op = cancel;