Utilizing the built-in 'messages' forums feature


#1

So I ‘accidentally’ ran across this part of your Forums Profile (press G+M).

I don’t believe this can be accessed by just clicking, but could we see integration with the actual RealmEye messaging system?


#2

I would think this is in beta for only the mods to use and test atm … how the fuck did you doo this on accident


#3

(head smash into keyboard)

That’s possible… but I just found this:

I guess it was disabled for a reason :confused:


#4

We only get automatic messages through that message board from the forum system (spam flags, sock puppet account flags, etc).

I did create a Chrome Extension to make life a little easier while moderating with automatic mod note generation and RealmEye Message notifications.

Although I could make an extension that just has the notifications, it makes frequent requests and I would feel bad freely distributing something that adds extra background load to the system.


#5

Alright, thanks for the info. I do think Doc’s solution would serve the purpose of notifying the user of new messages


#6

Here’s the javascript to handle turning that icon orange.

It’s a great idea but it does make a request to the “Messages of player” page every 5 seconds (although that interval can be changed in the code).

@MrEyeball, if you think it’d be fine and it’s a good idea I hope this snippet is of some use. Otherwise @UnicornSla you can probably inject that snippet using something like Tampermonkey.

/**
 * Do whatever you need with the message count
 * @param {Number} _count
 */
var re_msg_count = function(_count){

  // Turn the navbar toggle icon orange
  var _arrow_icon = document.getElementById('realmeye-navbar-toggle');

  if(_arrow_icon){

    _arrow_icon.style.color = (_count > 0 ? '#F67E42' : '');

  }

};


/**
 * Self invoking get RealmEye message count function
 */
(function(){

  /**
   * Core variables
   * @type {Object}
   */
  var re_msg = {
    get_user:          new XMLHttpRequest(),
    user_data:         null,
    username:          null,
    message_loop:      false,
    loop_interval:     5000,
    get_message_count: null
  };


  /**
   * Get message count
   */
  re_msg.get_message_count = function(){

    // Set up request
    var _message_request = new XMLHttpRequest();
    _message_request.open('GET', '/messages-of-player/' + re_msg.username, true);

    // Response handler
    _message_request.onreadystatechange = function(){

      var _message_count = 0;

      if(_message_request.readyState == 4 && _message_request.status == 200){

        // Match to find button link
        var _pattern = new RegExp('(?:<a href="\\/messages-of-player\\/' + re_msg.username + '">Messages\\s)\\((\\d+)\\)', 'im');
        var _matches = _message_request.responseText.match(_pattern);

        if(_matches && _matches[1] && _matches[1].match(/\d+/)){
          // Matched message count as int
          message_count = _matches[1] * 1;
        }

        // Loop get_message_count
        re_msg.message_loop = window.setTimeout(re_msg.get_message_count, re_msg.loop_interval);

        // Process message count
        if(re_msg_count){
          re_msg_count(_message_count);
        }

      }

    }

    // Send request
    _message_request.send();

  };


  /**
   * Initial retrieval of current user data via Discourse API
   */
  re_msg.get_user.open('GET', '/forum/session/current.json', true);

  // Response handler
  re_msg.get_user.onreadystatechange = function(){

    if(re_msg.get_user.readyState == 4 && re_msg.get_user.status == 200){

      // Parse JSON
      re_msg.user_data = JSON.parse(re_msg.get_user.responseText);

      if(re_msg.user_data && re_msg.user_data.current_user){

        // Set username
        re_msg.username = re_msg.user_data.current_user.username;

        // Run message count loop if current user available
        re_msg.get_message_count();

      }

    }

  };

  // Send request
  re_msg.get_user.send();

})();

#7

Thanks for the code, though I’m not very code-savvy and currently don’t have the time to figure it out, but I’m sure some people would be able to!

This is sorta a roundabout solution; I’d rather have full integration (i.e. same system so RealmEye Messages automatically sends a notification to the forums) because as you said, it might put a lot of extra strain to the system.

Or maybe even use the forums messaging system for the RealmEye Messages feature.


#8

A little update on this:

I’m loving the notifications that appear on the Toggle RealmEye Menu button but I find that I’m clicking on that, and clicking another two times to get to my messages.

I know this sounds really whiny but could it be possible to have the notifications pop up where the other notifications do?

Something like that?

@BMJ do you think this would be possible? Just making more work xD


#9

Bumpity bump since BMJ is ded. Anyone else know how to code? xD


#10

BMJ and MrEyeball are the pros. I’m just an amateur.


#11

Naw mahn… you’re the Doc!

Forgive me Lord Shaitan of my sins and transgressions…

BMJ’s ded tho ;-;


#12

same with @otherbill and @mattyfatty


#13

That is untrue, Mattfatty was seen 2 hours ago.


#14

oh rip, well, he’s a lot less active i guess.


#15

Na I’m still here. Very busy at the moment though so haven’t had time to be as active.


#16

Reports of my death are greatly exaggerated.

 


[Seriously, working 60-hour weeks while going through a 200-hour training certification doesn't leave much time for anything else. OB]

#17

wow…[quote=“OtherBill, post:16, topic:1736”]
200-hour training certification
[/quote]

even more wow…


#18

Be more careful, leeking classified regualr-only content through your notifications…


#19

? There’s nothing there

Edit: Ah I see. 1 . No harm done 2 thanks for further confirming whom you are.


#20

Thanks I will. Good thing nobody noticed until months later :sweat_smile:.

Back to the original topic, it would also be nice to have some indication that you have a forums notification while you’re browsing the normal RealmEye website. Perhaps something glowing on the tab that says Forum.