diff --git a/app/controllers/search.go b/app/controllers/search.go index dff23fa2db31fa7ab218eb553c76e21c37c0dd2f..913be38a92852b4cd6c650b7eadf632b8799fec7 100644 --- a/app/controllers/search.go +++ b/app/controllers/search.go @@ -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) } diff --git a/app/controllers/user.go b/app/controllers/user.go index d932266ea76c5b44b4932ba65e15d4346fb5357c..f8624144b53fc454d5310bc1e09abac1beb624ab 100644 --- a/app/controllers/user.go +++ b/app/controllers/user.go @@ -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", }, }, diff --git a/app/controllers/webfinger.go b/app/controllers/webfinger.go index 49f7bcbc69fa4c6bd500f6aa294698addfc423e4..e82df51e955b4fbf12518c2fdaadccc2b5cd18cd 100644 --- a/app/controllers/webfinger.go +++ b/app/controllers/webfinger.go @@ -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) diff --git a/app/helpers/configuration.go b/app/helpers/configuration.go index 41d6b67ea1fa6f04c1b1ee00fad7f64e179daf13..842aabcf70042d487bd738bd499821217d3f1ee0 100644 --- a/app/helpers/configuration.go +++ b/app/helpers/configuration.go @@ -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") } diff --git a/app/helpers/parse_strings.go b/app/helpers/parse_strings.go index 79c91369cf27203aeaf78af4ae35df546226af09..72222961f56625f52a1528e827614bf241b4b4ca 100644 --- a/app/helpers/parse_strings.go +++ b/app/helpers/parse_strings.go @@ -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 diff --git a/app/jobs/dispatch_comment.go b/app/jobs/dispatch_comment.go index e3c5e7192dfcda6c7186fedef254b1b8d27792f6..abda13341bf6e22f6ae590aff27b455e08930cbf 100644 --- a/app/jobs/dispatch_comment.go +++ b/app/jobs/dispatch_comment.go @@ -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) diff --git a/app/jobs/dispatch_like.go b/app/jobs/dispatch_like.go index 35e71cdf9206e986a126da64ce5c4ea9996694f9..529b96baef8fce1cd606f92b5567e35afb13d928 100644 --- a/app/jobs/dispatch_like.go +++ b/app/jobs/dispatch_like.go @@ -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 diff --git a/app/jobs/dispatch_post.go b/app/jobs/dispatch_post.go index 75f95eec624c1ca72d6671c164856c6e840b5433..fd77ac08f6c142170d18d3198783dfc554380c07 100644 --- a/app/jobs/dispatch_post.go +++ b/app/jobs/dispatch_post.go @@ -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 diff --git a/app/jobs/dispatcher.go b/app/jobs/dispatcher.go index 0cc1e280f649a5e5ed6a1cf1b71185991a3dde8d..e9b435ed0ce8ad27ba410ff0e4102ca4dc7a1cfb 100644 --- a/app/jobs/dispatcher.go +++ b/app/jobs/dispatcher.go @@ -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 { diff --git a/app/jobs/fetch_author.go b/app/jobs/fetch_author.go index adfd13f67ca778f5766af8fb080718681ca9a9c0..dd2e62af9f2d7e1b61806f1b3cbee9f75f220b32 100644 --- a/app/jobs/fetch_author.go +++ b/app/jobs/fetch_author.go @@ -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 diff --git a/app/jobs/receiver.go b/app/jobs/receiver.go index 70653fd7dd709f99ecc67af0d3ad604dfbb4f258..da5061b82afa3cca25e3b9a47619ca15fc4420b7 100644 --- a/app/jobs/receiver.go +++ b/app/jobs/receiver.go @@ -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 diff --git a/app/jobs/relay_comment.go b/app/jobs/relay_comment.go index 2d387883860ceafdea2c2014a6325fc29dc3e2b4..8c12bc77da3ba32664d70952d25205bb9ac9aa2e 100644 --- a/app/jobs/relay_comment.go +++ b/app/jobs/relay_comment.go @@ -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 diff --git a/app/models/comments.go b/app/models/comments.go index bbf4435d44012fdc693df941d6223fc9257f7b2a..baea6e38fdc0a85e4a56014a8050540f32baa9db 100644 --- a/app/models/comments.go +++ b/app/models/comments.go @@ -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 } diff --git a/app/models/contacts.go b/app/models/contacts.go index eec9042d95751f06ecf5b423e101bdb3022d8eb2..6d1c748b95c0fe9329104fd89715b0a0fef3d5c0 100644 --- a/app/models/contacts.go +++ b/app/models/contacts.go @@ -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 } diff --git a/app/models/init.go b/app/models/init.go index 6904db398814f95cc6b36825017a827aca54ee1b..b7b0e34c35de529c866901b4e1d84d890cba0ed3 100644 --- a/app/models/init.go +++ b/app/models/init.go @@ -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") diff --git a/app/models/likes.go b/app/models/likes.go index a5abe8583859e4500297e6d443cd3b0c6195280b..7ae90e22ea57f3332c4f4e447085a05a70363c5a 100644 --- a/app/models/likes.go +++ b/app/models/likes.go @@ -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 } diff --git a/app/models/posts.go b/app/models/posts.go index b73db2f4f9c705193091a1ea1935498c5e5276d8..e1f9cf5adf5b84f0eb3b475739e69e9b09d17a7a 100644 --- a/app/models/posts.go +++ b/app/models/posts.go @@ -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 } diff --git a/app/models/profiles.go b/app/models/profiles.go index 8be5885dc7885851a18fb2655ab70c3678df0b3b..db772000dca1790bbe0d0267a34b99a6b790d34e 100644 --- a/app/models/profiles.go +++ b/app/models/profiles.go @@ -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 } diff --git a/app/views/profile/index.html b/app/views/profile/index.html index 29debb923d29278a2e031e3e319bab4dd20376a3..9ad153d8406e80e736792321fbbd3287f7c59c5c 100644 --- a/app/views/profile/index.html +++ b/app/views/profile/index.html @@ -12,7 +12,7 @@ -

{{$profile.DiasporaHandle}}

+

{{$profile.Author}}


diff --git a/app/views/stream/comment.html b/app/views/stream/comment.html index f6eff57eb6904f2c979d6748e1b98664f80ae79d..66b8bd099e1336455fa11d28fa490f4c054f7ccf 100644 --- a/app/views/stream/comment.html +++ b/app/views/stream/comment.html @@ -11,7 +11,7 @@
-
{[{Person.DiasporaHandle}]}
+
{[{Person.Author}]}
diff --git a/app/views/stream/post.html b/app/views/stream/post.html index fe1af48da0d651f76543ec3d2c4641b4eb3b80dd..7b625566fc63736075306f40452bd1ebc533109d 100644 --- a/app/views/stream/post.html +++ b/app/views/stream/post.html @@ -11,7 +11,7 @@
-
{[{Profile.DiasporaHandle}]}
+
{[{Profile.Author}]}
diff --git a/app/views/stream/reshare.html b/app/views/stream/reshare.html index 55a7b0ca53e628da8af6e0616bf2bd61bdba2656..9e2430c9f9c67f4e942e963350728d11f58a344e 100644 --- a/app/views/stream/reshare.html +++ b/app/views/stream/reshare.html @@ -2,6 +2,6 @@ {{$profile := $person.Profile}}
-

{{$profile.DiasporaHandle}}

+

{{$profile.Author}}

{{.Text}}

diff --git a/app/views/template.go b/app/views/template.go index 726b54fce584ef0fb3e4baf89180c3ad3f1c7bc1..3838b6355959e4ef80f4403bc0acf2a4924a2963 100644 --- a/app/views/template.go +++ b/app/views/template.go @@ -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