pump-io / pump.io

Social server with an ActivityStreams API
http://pump.io/
Apache License 2.0
2.22k stars 333 forks source link

Commenting problem "Error: no original post" #1027

Open mnd opened 10 years ago

mnd commented 10 years ago

I can't comment any public messages on pump.io servers except my own server.

For example when I try to post comment to https://pumprock.net/mnd/note/mfUo6VMgTUSdEckfEcbVOg being logined from my mnd@pump.mndet.net account pumprock.net server send to my server POST request

162.243.140.159 - - [09/Jun/2014:00:28:56 -0400] "POST /api/user/mnd/feed HTTP/1.1" 500 841 "-" "pump.io/0.3.0-alpha.1"

with POST body

{"verb":"post","object":{"objectType":"comment","content":"test me<br>","inReplyTo":{"objectType":"note","content":"New post for testing comments from pump.mndet.net<br>","published":"2014-06-08T22:21:04Z","updated":"2014-06-08T22:21:04Z","links":{"self":{"href":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg"}},"likes":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/likes","totalItems":0,"items":[]},"replies":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/replies","totalItems":0,"items":[]},"shares":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/shares","totalItems":0,"items":[]},"url":"https://pumprock.net/mnd/note/mfUo6VMgTUSdEckfEcbVOg","id":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg","liked":false,"pump_io":{"shared":false}}}}

and my pump.io server return error:

[2014-06-09T04:28:56.371Z] ERROR: pump.io/22751 on mndet: no original post (req.remoteAddress=127.0.0.1, req.remotePort=52813)
    POST /api/user/mnd/feed HTTP/1.1
    host: pump.mndet.net
    connection: upgrade
    x-real-ip: 162.243.140.159
    authorization: OAuth oauth_consumer_key="3FzZpHIzsqkzxI9U_M70zw",oauth_nonce="aKZBme7lmvX7nm14FL9f3UOK7jVJYKMW",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1402288126",oauth_token="x0SbL8i4IR5VEnlJ4pbgyA",oauth_version="1.0",oauth_signature="%2BFqugxIm8r8n%2FJ3sS3BGa07WOjQ%3D"
    user-agent: pump.io/0.3.0-alpha.1
    content-length: 2763
    content-type: application/json
    --
    Error: no original post
        at Function.<anonymous> (/home/pumpio/pump.io/lib/model/activity.js:990:30)
        at next (/home/pumpio/pump.io/node_modules/step/lib/step.js:51:23)
        at Function.<anonymous> (/home/pumpio/pump.io/lib/model/activity.js:1733:17)
        at next (/home/pumpio/pump.io/node_modules/step/lib/step.js:51:23)
        at Function.<anonymous> (/home/pumpio/pump.io/lib/model/activity.js:1704:21)
        at next (/home/pumpio/pump.io/node_modules/step/lib/step.js:51:23)
        at /home/pumpio/pump.io/node_modules/databank/lib/databankobject.js:131:35
        at /home/pumpio/node_modules/databank-mongodb/lib/mongodb.js:511:33
        at /home/pumpio/node_modules/databank-mongodb/node_modules/mongodb/lib/mongodb/cursor.js:240:33
        at /home/pumpio/node_modules/databank-mongodb/node_modules/mongodb/lib/mongodb/cursor.js:658:35
Error: no original post
[2014-06-09T04:28:56.372Z]  INFO: pump.io/web/22751 on mndet:  (req_id=cc8846f2-b310-4f80-ba89-492f2c04f505, serverTime=39, req.remoteAddress=127.0.0.1, req.remotePort=52813)
    POST /api/user/mnd/feed HTTP/1.1
    host: pump.mndet.net
    connection: upgrade
    x-real-ip: 162.243.140.159
    authorization: OAuth oauth_consumer_key="3FzZpHIzsqkzxI9U_M70zw",oauth_nonce="aKZBme7lmvX7nm14FL9f3UOK7jVJYKMW",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1402288126",oauth_token="x0SbL8i4IR5VEnlJ4pbgyA",oauth_version="1.0",oauth_signature="%2BFqugxIm8r8n%2FJ3sS3BGa07WOjQ%3D"
    user-agent: pump.io/0.3.0-alpha.1
    content-length: 2763
    content-type: application/json
    --
    HTTP/1.1 500 Internal Server Error
    X-Powered-By: Express
    Vary: Accept-Encoding
    Server: pump.io/0.3.0-alpha.1 express/2.5.11 node.js/v0.10.26
    Content-Type: text/plain
    Date: Mon, 09 Jun 2014 04:28:56 GMT
    Connection: keep-alive
    Transfer-Encoding: chunked
    --
    principal: {
      "id": "acct:mnd@pump.mndet.net",
      "type": "person"
    }
    --
    client: {
      "key": "3FzZpHIzsqkzxI9U_M70zw",
      "title": "pumprock.net"
    }

Same error I get when try to comment any other post. Same error I get when try to comment posts like https://pump.saz.im/sazius/note/-6ja4kRJT6qq-tuTCuCrNw writed by people followed by me.

I use pump.io server from git https://github.com/e14n/pump.io/tree/590281f3f470bb2c5b42d0af1ab05736bfe8bc62

What can I do to repair my pump.io installation?

jankusanagi commented 10 years ago

Do you follow those people whose posts you can't comment on?

I've seen the "No original post" error, but usually only on posts from people I didn't follow, that I saw reshared, or via a "someoneIfollow posted a comment in reply to a_note_from_someone_I_don't".

mnd commented 10 years ago

Seems that your assumptions is correct. If I 1. follow mnd@pumprock.net, 2. post message from mnd@pumprock.net, 3. comment this message from mnd@pump.mndet.net then all works. But if message was posted before I follow author of the message then I can't comment message.

Also it's not necessary to follow people by itself. mnd@pumprock.net not follow anybody, but I can comment from this account messages like https://pump.saz.im/sazius/note/-6ja4kRJT6qq-tuTCuCrNw . Probably it happens because on pumprock.net exist users who follow sazius@pump.saz.im

Thank you for your help.

jankusanagi commented 9 years ago

This issue should be re-opened, since the issue itself is not fixed, and it brings a lot of problems.

I would open a new one, but this one is very well explained and very detailed as it is ;)

mnd commented 9 years ago

This issue should be re-opened, since the issue itself is not fixed, and it brings a lot of problems.

Yes, you right. Reopen.

jankusanagi commented 9 years ago

Thanks! =)

larjona commented 9 years ago

Related? #885 and #742

mnd commented 9 years ago

I look a little at the code and yes, this issue related to #885 because both issues work through same API, but I think this issue and #885 must be solved in different ways: for #885 we can choose default "to" and "cc" fields, for this issue we must found way to get original post recipients. Issue described by @alphakamp in comment to #742 probably same as this issue. I don't think it's related to #742 itself.

Now about problem: When we try to create comment server get POST request (from first message of this issue):

{"verb":"post",
 "object":{
   "objectType":"comment",
   "content":"test me<br>",
   "inReplyTo":{
     "objectType":"note",
     "content":"New post for testing comments from pump.mndet.net<br>",
     "published":"2014-06-08T22:21:04Z",
     "updated":"2014-06-08T22:21:04Z",
     "links":{"self":{"href":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg"}},
     "likes":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/likes","totalItems":0,"items":[]},
     "replies":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/replies","totalItems":0,"items":[]},
     "shares":{"url":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg/shares","totalItems":0,"items":[]},
     "url":"https://pumprock.net/mnd/note/mfUo6VMgTUSdEckfEcbVOg",
     "id":"https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg","liked":false,"pump_io":{"shared":false}}}}

function Activity.prototype.ensureRecipients from pump.io/lib/model/activity.js try to create fields "to" and "cc" with help of function Activity.postOf by single request

Activity.search({verb: verb, "object.id": object.id}, this);

Where object.id is POST_REQUEST.object.inReplyTo.id field. For mongodb and described above POST request we just call

db.activity.find({ "verb" : "post", "object.id" : "https://pumprock.net/api/note/mfUo6VMgTUSdEckfEcbVOg" })

And so if our server not get original activity (exactly "verb":"post", not "verb":"share") then we don't know which values we must set for "to" and "cc" fields.

Suddenly we also can't use pumpa variant of commenting realisation: When you try post comment on shared message pumpa copies to comment "to" and "cc" fileds from "verb":"share" message.

Example: Original post:

{ "verb" : "post",
  "object" : { "id" : "https://identi.ca/api/note/x0X7nVUkT_CWiN0E8_N35Q", "objectType" : "note" },
  "to" : [  {   "id" : "http://activityschema.org/collection/public",   "objectType" : "collection" } ],
  "cc" : [  {   "id" : "https://identi.ca/api/user/davexunit/followers",    "objectType" : "collection" } ],

Shared message (same message!)

{ "verb" : "share",
  "object" : { "id" : "https://identi.ca/api/note/x0X7nVUkT_CWiN0E8_N35Q", "objectType" : "note" }, 
  "cc" : [  {   "id" : "https://identi.ca/api/user/cwebber/followers",  "objectType" : "collection" } ],

As result with pumpa version of realisation we can get messages like:

{ "verb" : "post",
  "object" : { "id" : "https://io.mndet.net/api/comment/Ol5PIl1GQm6KG0E2_5-GjQ", "objectType" : "comment" },
  "to" : [ { "id" : "acct:sazius@pump.saz.im", "objectType" : "person" } ],
  "cc" : [  {   "id" : "https://microca.st/api/user/clacke/followers",  "objectType" : "collection" } ],

where "cc" is followers of person who share message, not sender. In web interface this type of comments also not displayed (must be created as another server bug, or as pumpa bug?)

Conclusion: To resolve problem, as I understand, we must change protocol:

  1. When we Share (or likes, because client programs can get messages from Like activity) message we must send not only message (message id for likes), but also original "to" and "cc" fields
  2. When commenting through web interface we must send to commenter's server not only original post "id", but also original "to" and "cc", or probably whole post as it was send to original recipients.

And probably we must create bug in Pumpa bugtracker.

shtrom commented 9 years ago

:+1:

ghost commented 9 years ago

Hello Everyone,

I am developing social app using pump.io stream server on my iOS app. I am successfully logged-In and also get the logged-In user details using OAuth. But facing problem to POST new activity. Like i want to POST notes on public(feeds). I have done the same thing as you mentioned above and my app URL which i am using to post new activity : https://hostname/api/user/nickname/feed and also add the OAuth Authorization. My code is:

NSDictionary *objectTOPost = @{ @"id" : [NSString stringWithFormat:@"%@collection/public", kBASEURL], @"objectType" : @"collection" }; // Store to in arrayTo...... [arrayTo addObject:objectTOPost];

NSMutableArray *arrayCC = [[NSMutableArray alloc] init];
// Create 'cc' Key......
NSDictionary *objectCCPost = @{
                             @"cc"              : [NSString stringWithFormat:@"%@api/user/%@/followers", kBASEURL, strNickName],
                             @"objectType"      : @"collection"
                             };
// Store CC key in Array....
[arrayCC addObject:objectCCPost];

// Add all objects in dictioanry and create key's... NSDictionary *jsonObjectPost = @{ @"verb" : @"post", @"object" : @{ @"id" : [NSString stringWithFormat:@"%@api/note/%@", kBASEURL, strAccountID], @"objectType" : @"note", @"content" : @"12345acct:shiju" }, @"to" : arrayTo, @"cc" : arrayCC };

But i got error and my error is: Printing description of operation:

<AFHTTPRequestOperation: 0x7fe13242df40, state: isFinished, cancelled: NO request: <NSMutableURLRequest: 0x7fe132477590> { URL: https://hostname/api/user/shiju86.v/feed }, response: <NSHTTPURLResponse: 0x7fe1325aef40> { URL: https://hostname/api/user/shiju86.v/feed } { status code: 400, headers { Connection = "keep-alive"; "Content-Type" = "text/plain"; Date = "Mon, 16 Mar 2015 11:31:54 GMT"; Server = "pump.io/0.3.0 express/2.5.11 node.js/v0.10.33"; "Transfer-Encoding" = Identity; Vary = "Accept-Encoding"; "Www-Authenticate" = "OAuth realm=\"OAuth\""; "X-Powered-By" = Express; } }> Error: Request failed: bad request (400)

Please look at my error. How could i POST? You can email me in shiju.varghese@dekhdekh.com

Regards Shiju Varghese

ghost commented 6 years ago

Same error "msg":"no original post" when I tried to comment a user that I not follow