ajones05 / seearound.me-ionic

0 stars 0 forks source link

If I edit a post, then try to edit again, location is removed #184

Closed ajones05 closed 7 years ago

ajones05 commented 7 years ago

Here is the process:

  1. Edit a post - make changes and save.
  2. Try to edit the same post. This time the location has been removed.
abdulhafeez commented 7 years ago

@yuriyua When I save a post after editing using mobile/save-post API, the Address field becomes empty string in the response although this field had an address before. Here is an example of the post without Address:

editPost called ... { "id":"4557", "user_id":"369", "category_id":"4", "news":"I think #meena is a beautiful actress. Test", "created_date":"2 months ago", "latitude":"31.5741177", "longitude":"74.41203519999999", "Address":"", "comment_count":"1", "vote":"11", "isLikedByUser":"1", "Name":"Abdul", "Profile_image":"http://www.seearound.me/uploads/1mssyv4pls.jpg", "canEdit":1, "canVote":1, "isFriend":0, "thumb":"http://www.seearound.me/thumb448x320/f13ch1s54y.jpg", "image":"http://www.seearound.me/uploads/f13ch1s54y.jpg" }

yuriyua commented 7 years ago

@abdulhafeez Address is empty because we missed the address details (street_number, street_name, city, state, country, zip) in the request parameters. You can see that response details:

2017-02-23T17:59:54+00:00 INFO (6): /mobile/save-post
>> array (
  'token' => '3PYVGS72328TYMA2LVC5M8R7363N5XD8MC567B79CE5A3ECNAPTZZM73S9QZ767V',
  'post_id' => '4557',
  'category_id' => '4',
  'body' => 'I think #meena is a beautiful actress. Test',
  'latitude' => '31.5741177',
  'longitude' => '74.41203519999999',
  'street_number' => '',
  'street_name' => '',
  'city' => '',
  'state' => '',
  'country' => '',
  'zip' => '',
  'image' => 'http://www.seearound.me/uploads/f13ch1s54y.jpg',
)
<< array (
  'status' => 'SUCCESS',
  'post' => 
  array (
    'category_id' => '4',
    'body' => 'I think #meena is a beautiful actress. Test',
    'latitude' => '31.5741177',
    'longitude' => '74.41203519999999',
    'thumb' => 'http://www.seearound.me/thumb448x320/f13ch1s54y.jpg',
    'image' => 'http://www.seearound.me/uploads/f13ch1s54y.jpg',
  ),
)
$_SERVER: array (
  'REDIRECT_STATUS' => '200',
  'HTTP_HOST' => 'www.seearound.me',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
  'CONTENT_TYPE' => 'application/x-www-form-urlencoded;charset=UTF-8',
  'HTTP_ACCEPT_LANGUAGE' => 'en-us',
  'HTTP_ACCEPT' => 'application/json, text/plain, */*',
  'HTTP_ORIGIN' => 'file://',
  'HTTP_COOKIE' => 'user_session=38hjj081jmqidjbofv2dpscvo7',
  'CONTENT_LENGTH' => '328',
  'HTTP_CONNECTION' => 'keep-alive',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Mobile/14A456 (374529616)',
  'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  'SERVER_SIGNATURE' => '<address>Apache/2.4.18 (Ubuntu) Server at www.seearound.me Port 80</address>
',
  'SERVER_SOFTWARE' => 'Apache/2.4.18 (Ubuntu)',
  'SERVER_NAME' => 'www.seearound.me',
  'SERVER_ADDR' => '172.31.0.55',
  'SERVER_PORT' => '80',
  'REMOTE_ADDR' => '103.255.4.85',
  'DOCUMENT_ROOT' => '/var/www/html/web',
  'REQUEST_SCHEME' => 'http',
  'CONTEXT_PREFIX' => '',
  'CONTEXT_DOCUMENT_ROOT' => '/var/www/html/web',
  'SERVER_ADMIN' => 'webmaster@localhost',
  'SCRIPT_FILENAME' => '/var/www/html/web/index.php',
  'REMOTE_PORT' => '8310',
  'REDIRECT_URL' => '/mobile/save-post',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'REQUEST_METHOD' => 'POST',
  'QUERY_STRING' => '',
  'REQUEST_URI' => '/mobile/save-post',
  'SCRIPT_NAME' => '/index.php',
  'PHP_SELF' => '/index.php',
  'REQUEST_TIME_FLOAT' => 1487872794.299,
  'REQUEST_TIME' => 1487872794,
)
abdulhafeez commented 7 years ago

@yuriyua Address details are not present in the original post but Address is. To me, it does not make sense to make Address from details in case of save-post. It should be saved as it is with new changes.

abdulhafeez commented 7 years ago

screenshot 2017-03-02 02 36 36

JSON after savePost called ... shows the data from original post. See that details are empty while Address has a string. Response does not show Address.

yuriyua commented 7 years ago

@abdulhafeez Are you used /mobile/post api for load post details for edit form?

abdulhafeez commented 7 years ago

No, I do not use mobile/post api to load post details. I pick the post from the list when user taps on 'Edit Post'. Thats how it is done in mobile apps.

yuriyua commented 7 years ago

I added full address details to post api responses:

mobile/post mobile/myposts mobile/request-neares

https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference/_compare/9b874d0def5f23e8368ffe39bf0fdc19f89f9c4e...46e06494a97a897cf9f2dff575f238c2c5ff0254

abdulhafeez commented 7 years ago

@yuriyua Sorry, it seems you have done the opposite. 'Address' is still empty which is actually required. The 'Address' is there in the post before saving but is removed after saving. That is the problem. Other details are irrelevant in this case.

yuriyua commented 7 years ago

@abdulhafeez We do not use Address value in post form. We use address details values: https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference#-mobilesave-post

Parameter name Value Required Description
... ... ... ...
latitude string yes The post location latitude
longitude string yes The post location longitude
street_name string no The post address street name
street_number string no The post address street number
city string no The post address city
state string no The post address state
country string no The post address country
zip string no The post address zip code
... ... ... ...

You should send full address details to save post api. We generate full address (field Address) from these values.

My tests

Post details http://www.seearound.me/admin/mobile-api/post/token/K1438YMTYBTNADFNBMF43IY5CVF5G6G47L7EKTAI669GKP6XDM2G71LIV4PDA8GG/post_id/4964/submit

Edit post reqwuest

{
    "status": "SUCCESS",
    "post": {
        "id": "4964",
        "user_id": "276",
        "category_id": "1",
        "news": "test",
        "created_date": "1 minute ago",
        "latitude": "46.47742532280709",
        "longitude": "30.73938560381066",
        "Address": "32 Rishelievska Street, Odesa, Odessa Oblast, UA",
        "street_name": "Rishelievska Street",
        "street_number": "32",
        "city": "Odesa",
        "state": "Odessa Oblast",
        "country": "UA",
        "zip": null,
        "comment_count": "0",
        "vote": "0",
        "isLikedByUser": "0",
        "Name": "Yuriy",
        "Profile_image": "http://www.seearound.me/uploads/3pyn6afcr3.jpg",
        "canEdit": 1,
        "canVote": 1,
        "isFriend": 0
    }
}

Save post request

{
    "token": "K1438YMTYBTNADFNBMF43IY5CVF5G6G47L7EKTAI669GKP6XDM2G71LIV4PDA8GG",
    "post_id": "4964",
    "body": "test (updated)",
    "latitude": "46.47742532280709",
    "longitude": "30.73938560381066",
    "street_name": "Rishelievska Street",
    "street_number": "32",
    "city": "Odesa",
    "state": "Odessa Oblast",
    "country": "UA"
}

Save post response

{
    "status": "SUCCESS",
    "post": {
        "category_id": null,
        "body": "test (updated)",
        "latitude": "46.47742532280709",
        "longitude": "30.73938560381066",
        "address": "32 Rishelievska Street, Odesa, Odessa Oblast, UA",
        "street_name": "Rishelievska Street",
        "street_number": "32",
        "city": "Odesa",
        "state": "Odessa Oblast",
        "country": "UA"
    }
}

We use address different format. For example we hide street number in the profile details. We need to store separated address values.

Please let me know if you will need more details from my side.