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

Allow requesting both read and unread messages in core_message_get_messages

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0
    • 3.11.3, 4.0
    • Web Services
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-72587-master
    • 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.

      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.

            dpalou Dani Palou
            dpalou Dani Palou
            Juan Leyva Juan Leyva
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.