Commit 43ca1b4e authored by zauberstuhl's avatar zauberstuhl

Rename DiasporaHandle into Author

parent 56b06399
......@@ -31,7 +31,7 @@ func (s Search) Create() revel.Result {
var searchText string
s.Params.Bind(&searchText, "search")
_, _, err := helpers.ParseDiasporaHandle(searchText)
_, _, err := helpers.ParseAuthor(searchText)
if err != nil {
return s.Redirect(Stream.Index)
}
......
......@@ -140,10 +140,11 @@ func (u User) Create() revel.Result {
EncryptedPassword: string(passwordEncoded),
Person: models.Person {
Guid: guid,
DiasporaHandle: username + "@" + host,
Author: username + "@" + host,
SerializedPublicKey: string(pubEncoded),
Profile: models.Profile{
DiasporaHandle: username + "@" + host,
Author: username + "@" + host,
Searchable: true,
ImageUrl: "/public/img/avatar.png",
},
},
......
......@@ -69,8 +69,7 @@ func (c Webfinger) Webfinger() revel.Result {
defer db.Close()
var person models.Person
err = db.Where("diaspora_handle = ?",
username + "@" + address).First(&person).Error
err = db.Where("author = ?", username + "@" + address).First(&person).Error
if err != nil {
c.Response.Status = http.StatusNotFound
revel.TRACE.Println(err)
......
......@@ -26,7 +26,7 @@ func IsLocalHandle(handle string) bool {
panic("No server address configured")
}
_, host, err := ParseDiasporaHandle(handle)
_, host, err := ParseAuthor(handle)
if err != nil {
panic("Cannot parse diaspora handle")
}
......
......@@ -22,7 +22,7 @@ import (
"errors"
)
func ParseDiasporaHandle(handle string) (string, string, error) {
func ParseAuthor(handle string) (string, string, error) {
parts, err := _ParseStringHelper(handle, `^(.+?)@(.+?)$`, 2)
if err != nil {
return "", "", err
......
......@@ -30,7 +30,7 @@ import (
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
const COMMENT_SIG_ORDER = "diaspora_handle guid parent_guid text"
const COMMENT_SIG_ORDER = "author guid parent_guid text"
func (d *Dispatcher) Comment(comment *federation.EntityComment) {
db, err := gorm.Open(models.DB.Driver, models.DB.Url)
......@@ -46,7 +46,7 @@ func (d *Dispatcher) Comment(comment *federation.EntityComment) {
return
}
(*comment).DiasporaHandle = d.User.Person.DiasporaHandle
(*comment).Author = d.User.Person.Author
(*comment).Guid = guid
authorSig, err := federation.AuthorSignature(
......@@ -99,18 +99,18 @@ func (d *Dispatcher) Comment(comment *federation.EntityComment) {
revel.TRACE.Println("entityXml", string(entityXml))
if helpers.IsLocalHandle(d.ParentPerson.DiasporaHandle) {
if helpers.IsLocalHandle(d.ParentPerson.Author) {
var visibility models.AspectVisibility
err = visibility.FindByParentGuid(comment.ParentGuid)
if err != nil {
revel.ERROR.Println(err)
return
}
sendToAspect(visibility.AspectID, d.User.SerializedPrivateKey, comment.DiasporaHandle, entityXml)
sendToAspect(visibility.AspectID, d.User.SerializedPrivateKey, comment.Author, entityXml)
} else {
payload, err := federation.MagicEnvelope(
(*d).User.SerializedPrivateKey,
(*comment).DiasporaHandle,
(*comment).Author,
entityXml,
); if err != nil {
revel.ERROR.Println(err)
......
......@@ -23,7 +23,8 @@ import (
federation "gopkg.in/ganggo/federation.v0"
)
const LIKE_SIG_ORDER = "positive guid parent_guid target_type diaspora_handle"
// XXX remove and replace with database sort
const LIKE_SIG_ORDER = "positive guid parent_guid target_type author"
func (d *Dispatcher) Like(like *federation.EntityLike) {
authorSig, err := federation.AuthorSignature(
......@@ -59,8 +60,7 @@ func (d *Dispatcher) Like(like *federation.EntityLike) {
payload, err := federation.MagicEnvelope(
(*d).User.SerializedPrivateKey,
(*like).DiasporaHandle,
entityXml,
like.Author, entityXml,
)
// send it to the network
......
......@@ -39,13 +39,12 @@ func (d *Dispatcher) Post(post *federation.EntityStatusMessage) {
if d.AspectID > 0 {
sendToAspect(
d.AspectID, (*d).User.SerializedPrivateKey,
(*post).DiasporaHandle, entityXml,
post.Author, entityXml,
)
} else {
payload, err := federation.MagicEnvelope(
(*d).User.SerializedPrivateKey,
(*post).DiasporaHandle,
entityXml,
post.Author, entityXml,
); if err != nil {
revel.ERROR.Println(err)
return
......
......@@ -90,7 +90,7 @@ func sendToAspect(aspectID uint, priv, handle string, xml []byte) {
continue
}
_, host, err := helpers.ParseDiasporaHandle(person.DiasporaHandle)
_, host, err := helpers.ParseAuthor(person.Author)
if err != nil {
revel.ERROR.Println(err)
continue
......@@ -108,7 +108,6 @@ func sendToAspect(aspectID uint, priv, handle string, xml []byte) {
func send(wg *sync.WaitGroup, host, guid string, payload []byte) {
var err error
revel.Config.SetSection("ganggo")
localhost, found := revel.Config.String("address")
if !found {
......
......@@ -50,7 +50,7 @@ func (f *FetchAuthor) Run() {
}
defer db.Close()
_, host, err := helpers.ParseDiasporaHandle((*f).Author)
_, host, err := helpers.ParseAuthor(f.Author)
if err != nil {
revel.ERROR.Println(err)
(*f).Err = err
......
......@@ -92,8 +92,8 @@ func (r *Receiver) Run() {
revel.TRACE.Println("Found a profile entity")
insert := db.Where("diaspora_handle = ?",
r.Entity.Post.Profile.DiasporaHandle,
insert := db.Where("author = ?",
profileEntity.Author,
).First(&profile).RecordNotFound()
err := profile.Cast(r.Entity.Post.Profile)
......@@ -103,7 +103,7 @@ func (r *Receiver) Run() {
}
if !strings.HasPrefix(profile.ImageUrl, "http") {
_, host, err := helpers.ParseDiasporaHandle(profile.DiasporaHandle)
_, host, err := helpers.ParseAuthor(profile.Author)
if err != nil {
revel.ERROR.Println(err)
return
......
......@@ -85,14 +85,14 @@ func (r *Receiver) RelayComment(user models.User, visibilities models.AspectVisi
payload, err := federation.EncryptedMagicEnvelope(
user.SerializedPrivateKey,
person.SerializedPublicKey,
user.Person.DiasporaHandle,
user.Person.Author,
entityCommentXml,
); if err != nil {
revel.ERROR.Println(err)
return
}
_, host, err := helpers.ParseDiasporaHandle(person.DiasporaHandle)
_, host, err := helpers.ParseAuthor(person.Author)
if err != nil {
revel.ERROR.Println(err)
continue
......
......@@ -87,8 +87,7 @@ func (c *Comment) Cast(entity *federation.EntityComment) (err error) {
return
}
var person Person
err = db.Where("diaspora_handle = ?",
entity.DiasporaHandle).First(&person).Error
err = db.Where("author = ?", entity.Author).First(&person).Error
if err != nil {
return
}
......
......@@ -48,7 +48,7 @@ func (c *Contact) Cast(entity *federation.EntityRequest) (err error) {
}
defer db.Close()
username, _, err := helpers.ParseDiasporaHandle(entity.Recipient)
username, _, err := helpers.ParseAuthor(entity.Recipient)
if err != nil {
return err
}
......@@ -59,7 +59,7 @@ func (c *Contact) Cast(entity *federation.EntityRequest) (err error) {
return
}
err = db.Where("diaspora_handle = ?", entity.Sender).First(&sender).Error
err = db.Where("author = ?", entity.Author).First(&sender).Error
if err != nil {
return
}
......
......@@ -75,13 +75,13 @@ func InitDB() {
profile := &Profile{}
db.Model(profile).AddUniqueIndex("index_profiles_on_person_id", "person_id")
db.Model(profile).AddUniqueIndex("index_profiles_on_diaspora_handle", "diaspora_handle")
db.Model(profile).AddUniqueIndex("index_profiles_on_author", "author")
db.Model(profile).AddIndex("index_profiles_on_full_name_and_searchable", "full_name", "searchable")
db.Model(profile).AddIndex("index_profiles_on_full_name", "full_name")
db.AutoMigrate(profile)
person := &Person{}
db.Model(person).AddUniqueIndex("index_people_on_diaspora_handle", "diaspora_handle")
db.Model(person).AddUniqueIndex("index_people_on_author", "author")
db.Model(person).AddUniqueIndex("index_people_on_guid", "guid")
// NOTE not every person is a local user
//db.Model(person).AddUniqueIndex("index_people_on_user_id", "user_id")
......
......@@ -75,8 +75,7 @@ func (l *Like) Cast(entity *federation.EntityLike) (err error) {
return
}
err = db.Where("diaspora_handle = ?",
entity.DiasporaHandle).First(&person).Error
err = db.Where("author = ?", entity.Author).First(&person).Error
if err != nil {
return
}
......
......@@ -94,7 +94,7 @@ func (p *Post) Cast(post, reshare *federation.EntityStatusMessage) (err error) {
defer db.Close()
var person Person
err = db.Where("diaspora_handle = ?", entity.DiasporaHandle).First(&person).Error
err = db.Where("author = ?", entity.Author).First(&person).Error
if err != nil {
return
}
......
......@@ -59,7 +59,7 @@ func (p *Profile) Cast(entity *federation.EntityProfile) (err error) {
defer db.Close()
var person Person
err = db.Where("diaspora_handle = ?", entity.DiasporaHandle).First(&person).Error
err = db.Where("author = ?", entity.Author).First(&person).Error
if err != nil {
return
}
......@@ -69,7 +69,7 @@ func (p *Profile) Cast(entity *federation.EntityProfile) (err error) {
(*p).Birthday = birthday
}
(*p).DiasporaHandle = entity.DiasporaHandle
(*p).Author = entity.Author
(*p).FirstName = entity.FirstName
(*p).LastName = entity.LastName
(*p).ImageUrl = entity.ImageUrl
......@@ -87,7 +87,7 @@ func (p *Profile) Cast(entity *federation.EntityProfile) (err error) {
}
func (p Profile) Nickname() (nickname string) {
nickname, _, _ = helpers.ParseDiasporaHandle(p.DiasporaHandle)
nickname, _, _ = helpers.ParseAuthor(p.Author)
return
}
......
......@@ -12,7 +12,7 @@
<img src="{{$profile.ImageUrl}}" border="0" />
</div>
</header>
<h2>{{$profile.DiasporaHandle}}</h2>
<h2>{{$profile.Author}}</h2>
<hr/>
<form id="create-aspect">
<input type="text" style="display:none" id="personId" value="{{.person.ID}}">
......
......@@ -11,7 +11,7 @@
<div class="panel panel-default arrow left">
<div class="panel-body">
<header class="text-left">
<div class="comment-user"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {[{Person.DiasporaHandle}]}</div>
<div class="comment-user"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {[{Person.Author}]}</div>
<time class="comment-date" datetime="{[{CreatedAt}]}"><span class="glyphicon glyphicon-time" aria-hidden="true"></span> {[{CreatedAt}]}</time>
</header>
<div class="comment-post">
......
......@@ -11,7 +11,7 @@
<div class="panel panel-default arrow left">
<div class="panel-body">
<header class="text-left">
<div class="comment-user"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {[{Profile.DiasporaHandle}]}</div>
<div class="comment-user"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> {[{Profile.Author}]}</div>
<time class="comment-date" datetime="{[{CreatedAt}]}"><span class="glyphicon glyphicon-time" aria-hidden="true"></span> {[{CreatedAt}]}</time>
</header>
<div class="comment-post">
......
......@@ -2,6 +2,6 @@
{{$profile := $person.Profile}}
<div class="bs-callout bs-callout-info">
<h4 id="callout-progress-csp">{{$profile.DiasporaHandle}}</h4>
<h4 id="callout-progress-csp">{{$profile.Author}}</h4>
<p class="markdown">{{.Text}}</p>
</div>
......@@ -92,7 +92,7 @@ var TemplateFuncs = map[string]interface{}{
},
// string parse helper
"HostFromHandle": func(handle string) (host string) {
_, host, err := helpers.ParseDiasporaHandle(handle)
_, host, err := helpers.ParseAuthor(handle)
if err != nil {
revel.ERROR.Println(err)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment