Commit 43ca1b4e authored by zauberstuhl's avatar zauberstuhl

Rename DiasporaHandle into Author

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