Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72587

Allow requesting both read and unread messages in core_message_get_messages

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.11.3, 4.0
    • Fix Version/s: 4.0
    • Component/s: Web Services
    • Labels:
    • Affected Branches:
      MOODLE_311_STABLE, MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_400_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-72587-master
    • Testing Instructions:
      Hide
      1. You need Moodle instance with 2 users. I'll call them u1 and u2.
      2. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      3. Create a Token in the mobile app service for the u2 in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Login as both users and allow anyone in the site to message them:
        Click the message icon at the top ► Click the gear icon ► Select "Anyone on the site".
      5. Login as u1 and send a private message to u2.
      6. Login as u2 and open the conversation with u1. This should mark the message as read.
      7. As u2, go to your profile:
        Click your avatar ► Profile
      8. Remember the id in the URL of the profile page. E.g. if the URL is https://MYSITE/user/profile.php?id=3, the id is 3.
      9. Logout as u2.
      10. Login as u1 again and send a new private message to u2. Make sure the contents of the message are different than the previous one.
      11. Open the console an execute this curl request, replacing WSTOKEN with the token you just created and the site url with yours. The USERID value has to be replaced with the id you annotated before.

        curl 'http://SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'useridto=USERID&type=conversations&read=0&newestfirst=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_message_get_messages&wstoken=WSTOKEN' --compressed

      1. Confirm that you only receive one message: the second one you sent.
      2. Now execute the curl request again, but using read=1 instead of read=0.
      3. Confirm that you only receive one message: the first one you sent.
      4. Now execute the curl request again, but using read=2.
      5. Confirm that you receive both messages.
      Show
      You need Moodle instance with 2 users. I'll call them u1 and u2. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the u2 in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Login as both users and allow anyone in the site to message them: Click the message icon at the top ► Click the gear icon ► Select "Anyone on the site". Login as u1 and send a private message to u2. Login as u2 and open the conversation with u1. This should mark the message as read. As u2, go to your profile: Click your avatar ► Profile Remember the id in the URL of the profile page. E.g. if the URL is https://MYSITE/user/profile.php?id=3,  the id is 3. Logout as u2. Login as u1 again and send a new private message to u2. Make sure the contents of the message are different than the previous one. Open the console an execute this curl request, replacing WSTOKEN with the token you just created and the site url with yours. The USERID value has to be replaced with the id you annotated before. curl 'http://SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'useridto=USERID&type=conversations&read=0&newestfirst=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_message_get_messages&wstoken=WSTOKEN' --compressed Confirm that you only receive one message: the second one you sent. Now execute the curl request again, but using read=1 instead of read=0. Confirm that you only receive one message: the first one you sent. Now execute the curl request again, but using read=2. Confirm that you receive both messages.

      Description

      When calling the WebService core_message_get_messages you can only get either read messages or unread messages. It would be nice if the WebService allowed returning both of them in chronological order.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dpalou Dani Palou
              Reporter:
              dpalou Dani Palou
              Peer reviewer:
              Juan Leyva Juan Leyva
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 40 minutes
                  4h 40m