mirror of https://github.com/gophish/gophish
Adding DB table for template attachments (coming soon)
Cleanup API docs for campaigns Added "omitempty" for Campaign modelpull/24/head
parent
20fe32fd4e
commit
b3e411c54c
10
db/db.go
10
db/db.go
|
@ -40,11 +40,13 @@ func Setup() error {
|
|||
`CREATE TABLE targets (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT NOT NULL, UNIQUE(email));`,
|
||||
`CREATE TABLE groups (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, modified_date TIMESTAMP NOT NULL);`,
|
||||
`CREATE TABLE campaign_results (cid INTEGER NOT NULL, email TEXT NOT NULL, status TEXT NOT NULL, FOREIGN KEY (cid) REFERENCES campaigns(id), UNIQUE(cid, email, status))`,
|
||||
`CREATE TABLE templates (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, modified_date TIMESTAMP NOT NULL, html TEXT NOT NULL, text TEXT NOT NULL);`,
|
||||
`CREATE TABLE files (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, path TEXT NOT NULL);`,
|
||||
`CREATE TABLE user_campaigns (uid INTEGER NOT NULL, cid INTEGER NOT NULL, FOREIGN KEY (uid) REFERENCES users(id), FOREIGN KEY (cid) REFERENCES campaigns(id), UNIQUE(uid, cid))`,
|
||||
`CREATE TABLE user_groups (uid INTEGER NOT NULL, gid INTEGER NOT NULL, FOREIGN KEY (uid) REFERENCES users(id), FOREIGN KEY (gid) REFERENCES groups(id), UNIQUE(uid, gid))`,
|
||||
`CREATE TABLE group_targets (gid INTEGER NOT NULL, tid INTEGER NOT NULL, FOREIGN KEY (gid) REFERENCES groups(id), FOREIGN KEY (tid) REFERENCES targets(id), UNIQUE(gid, tid));`,
|
||||
`CREATE TABLE templates (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, modified_date TIMESTAMP NOT NULL, html TEXT NOT NULL, text TEXT NOT NULL);`,
|
||||
`CREATE TABLE user_templates (uid INTEGER NOT NULL, tid INTEGER NOT NULL, FOREIGN KEY (uid) REFERENCES users(id), FOREIGN KEY (tid) REFERENCES templates(id), UNIQUE(uid, tid));`,
|
||||
`CREATE TABLE template_files (tid INTEGER NOT NULL, fid INTEGER NOT NULL, FOREIGN KEY (tid) REFERENCES templates(id), FOREIGN KEY(fid) REFERENCES files(id), UNIQUE(tid, fid));`,
|
||||
}
|
||||
Logger.Printf("Creating db at %s\n", config.Conf.DBPath)
|
||||
//Create the tables needed
|
||||
|
@ -220,7 +222,7 @@ func GetGroup(id int64, uid int64) (models.Group, error) {
|
|||
return g, nil
|
||||
}
|
||||
|
||||
// GetGroup returns the group, if it exists, specified by the given name and user_id.
|
||||
// GetGroupByName returns the group, if it exists, specified by the given name and user_id.
|
||||
func GetGroupByName(n string, uid int64) (models.Group, error) {
|
||||
g := models.Group{}
|
||||
err := Conn.SelectOne(&g, "SELECT g.id, g.name, g.modified_date FROM groups g, user_groups ug, users u WHERE ug.uid=u.id AND ug.gid=g.id AND g.name=? AND u.id=?", n, uid)
|
||||
|
@ -338,6 +340,10 @@ func PostTemplate(t *models.Template, uid int64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func PutTemplate(t *models.Template, uid int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertTargetIntoGroup(t models.Target, gid int64) error {
|
||||
if _, err = mail.ParseAddress(t.Email); err != nil {
|
||||
Logger.Printf("Invalid email %s\n", t.Email)
|
||||
|
|
|
@ -40,8 +40,8 @@ type Campaign struct {
|
|||
CompletedDate time.Time `json:"completed_date" db:"completed_date"`
|
||||
Template string `json:"template"` //This may change
|
||||
Status string `json:"status"`
|
||||
Results []Result `json:"results" db:"-"`
|
||||
Groups []Group `json:"groups" db:"-"`
|
||||
Results []Result `json:"results,omitempty" db:"-"`
|
||||
Groups []Group `json:"groups,omitempty" db:"-"`
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
|
|
|
@ -145,8 +145,8 @@
|
|||
"Result": {
|
||||
"id": "Result",
|
||||
"properties": {
|
||||
"target": {
|
||||
"$ref": "Target"
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
|
@ -192,66 +192,15 @@
|
|||
"targets": {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "Target"
|
||||
"email" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"modified_date": {
|
||||
"type" : "date"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"id": "Pet",
|
||||
"description": "A pet is a person's best friend",
|
||||
"required": [
|
||||
"name",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "Tag"
|
||||
}
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "pet status in the store",
|
||||
"enum": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
},
|
||||
"category": {
|
||||
"$ref": "Category"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Category": {
|
||||
"id": "Category",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,9 +69,11 @@
|
|||
<div class="form-group">
|
||||
<input type="text" class="form-control" ng-model="group.name" placeholder="Group name" id="name" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-danger"><i class="fa fa-plus"></i> Bulk Import Users</button>
|
||||
</div>
|
||||
<fieldset disabled>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-danger"><i class="fa fa-plus"></i> Bulk Import Users (Coming Soon!)</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<label class="control-label" for="users">Users:</label>
|
||||
<form ng:submit="addTarget()">
|
||||
<div class="input-group">
|
||||
|
|
Loading…
Reference in New Issue