Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups
    1. Home
    2. truetuna
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 19
    • Best 4
    • Groups 0

    truetuna

    @truetuna

    4
    Reputation
    595
    Profile views
    19
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    truetuna Follow

    Best posts made by truetuna

    • RE: Redis server outdated, is actually v3.0.3

      In case anyone else in the future is reading this, I had the exact same problem when I was deploying NodeBB to AWS using the Ubuntu 14.04 LTS AMI.

      I had installed the latest version Redis by compiling from source (see tutorial here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis) but I had forgotten to uninstall the default redis-server package that came along with Ubuntu. After uninstalling the default redis-server package, the error message went away.

      sudo apt-get --purge autoremove redis-server
      
      posted in Technical Support
      truetuna
      truetuna
    • RE: How do I set default values for users after SSO?

      Thanks @julian.

      I was able to set the picture by extending the OAuth.login method (https://github.com/julianlam/nodebb-plugin-sso-oauth/blob/master/library.js#L160-L213).

      function _getAvatar(data) {
        ...
      }
      
      ...
      var success = function (uid) {
        // Save provider-specific information to the user
        User.setUserField(uid, constants.name + 'Id', payload.oAuthid);
        db.setObjectField(constants.name + 'Id:uid', payload.oAuthid, uid);
      
        var avatar = _getAvatar(payload.data);
        if (avatar) {
          User.setUserField(uid, 'picture', avatar);
          User.setUserField(uid, 'uploadedpicture', avatar);
        }
        ...
      

      I'm not sure why but just updating the picture didn't seem to work. I had to update uploadedpicture as well.

      The other thing I needed to do was change the settings. Turns out that user:*:settings isn't fully populated until I visit the settings page and click on "save settings". So what I ended up having to do was:

      var mySettings = {};   // Custom settings.
      User.saveSettings(uid, mySettings, function (err) {});
      

      and that seemed to work.

      posted in General Discussion
      truetuna
      truetuna
    • How can I read a resource only by their id (cid, uid, tid etc.) rather than the name or name+id?

      I'm trying to write a Python API wrapper over the NodeBB REST API but I'm a little confused by the interface. I understand that you can add /api to most if not all urls and be able to get json response.

      "https://community.nodebb.org/user/truetuna"
      "https://community.nodebb.org/api/user/truetuna"
      

      However, I'd prefer to reference a resource by their id rather than the associated username, topic name, category name etc.

      For example,

      # My username vs my uid.
      "https://community.nodebb.org/api/user/truetuna"
      "https://community.nodebb.org/api/user/6166"
      

      I ask because it seems like there's quite a split between the read-api and the write-api provided by the nodebb-plugin-write-api plugin. For example, if I wanted to PUT to a user, I have to reference the resource via the uid, but when I want to GET a user, I need to use their username.

      It's not too bad when it's the user resource but it gets pretty weird when it comes to say, topics. With topics, I need the tid AND the topic title. In addition, the topic title needs to be formatted in a specific way (removing commas, lowercase, replacing spaces with hyphens etc.).

      # The original title was "Deleted topics, comments"
      "https://community.nodebb.org/api/topic/6438/deleted-topics-comments"
      "https://community.nodebb.org/api/topic/6438/"
      

      It's very confusing and it makes it quite difficult to use the API.

      Am I missing something? Is it possible to reference resources just by their id? Is there a switch I need to turn on in the ACP for this to work? Is there a piece of documentation I'm missing?

      Because ideally, I'd prefer to only have to use the id as the resource reference, e.g.

      PUT, DELETE "https://community.nodebb.org/api/topic/6438/"
      PUT, DELETE "https://community.nodebb.org/api/user/6438/"
      PUT, DELETE "https://community.nodebb.org/api/category/6438/"
      ...
      

      Thanks

      PS. I'm using NodeBB v0.7.3

      posted in NodeBB Development
      truetuna
      truetuna
    • How are timestamps managed in NodeBB?

      I might be missing something but does NodeBB do something extra to timestamps? I'm trying to convert the "lastonline" timestamp to a datetime:

      ~/w/nodebb ❯❯❯ redis-cli
      127.0.0.1:6379> HGETALL user:1
      ...
      13) "lastonline"
      14) "1447135877476"
      ...
      

      0_1447482640618_Screenshot 2015-11-14 17.30.26.png

      but I end up getting something like the above.

      If I remove the last 3 digits, I get something a bit closer to the real time.

      0_1447482951157_Screenshot 2015-11-14 17.35.32.png

      Time is hard 😢. Can anyone explain what's going on?

      posted in Technical Support
      truetuna
      truetuna

    Latest posts made by truetuna

    • How are timestamps managed in NodeBB?

      I might be missing something but does NodeBB do something extra to timestamps? I'm trying to convert the "lastonline" timestamp to a datetime:

      ~/w/nodebb ❯❯❯ redis-cli
      127.0.0.1:6379> HGETALL user:1
      ...
      13) "lastonline"
      14) "1447135877476"
      ...
      

      0_1447482640618_Screenshot 2015-11-14 17.30.26.png

      but I end up getting something like the above.

      If I remove the last 3 digits, I get something a bit closer to the real time.

      0_1447482951157_Screenshot 2015-11-14 17.35.32.png

      Time is hard 😢. Can anyone explain what's going on?

      posted in Technical Support
      truetuna
      truetuna
    • RE: How do you sort topics/posts via the API?

      Could this be added to the API?

      https://community.nodebb.org/api/category/3/nodebb-development?sort=type

      Seems like a reasonable endpoint.

      posted in NodeBB Development
      truetuna
      truetuna
    • How do you sort topics/posts via the API?

      https://community.nodebb.org/api/category/3/nodebb-development

      ^ Sorts by topics by newest-oldest as default. I'd like to be able to sort by oldest - newest and most post as well... but I can't find any documentation on how I can do this.

      posted in NodeBB Development
      truetuna
      truetuna
    • RE: How do I pull user session objects from the Redis db?

      pinging @pitaj & @julian

      posted in Technical Support
      truetuna
      truetuna
    • RE: How do I pull user session objects from the Redis db?

      @pitaj Thanks!

      That sounds like a better solution. However I do see a problem as it would mean if I want to do the same for topics, groups and whatever else I'd have to have make lots of different API endpoints.

      Here's another idea, let me know if you think it's terrible. I extend the write-api to listen to all requests (not sure if there's a hook for that). In the request, I send up the same auth token I use for the write-api as well as the _uid of the user I'm impersonating. In the request hook I authenticate the request and set the authenticated user to be the user with the specified _uid.

      So when I hit /api/* then it will just know what user is being authenticated. Is any of this possible with NodeBB (v0.7.x branch)?

      posted in Technical Support
      truetuna
      truetuna
    • RE: How do I pull user session objects from the Redis db?

      @pitaj Yep I have access.

      posted in Technical Support
      truetuna
      truetuna
    • RE: How do I pull user session objects from the Redis db?

      @pitaj

      1. Nope - it's using Django
      2. Nope - separate server
      3. Yep I can do that

      Let me know if you need more information.

      posted in Technical Support
      truetuna
      truetuna
    • How do I pull user session objects from the Redis db?

      It looks like NodeBB is using express.sesson with the redis-connect store (or at least I am because I'm not using Mongo). I'm not too familiar with those libraries as I haven't really used NodeJS very much. I'm wondering if it's possible to pull user session objects so I can use them to authenticate my GET requests.

      I ask this because I'm trying to retrieve all categories via the API /api/categories. When I'm authenticated (using cookies in the browser), I'm able to get all categories but when I'm not authenticated, I'm only able to retrieve publicly accessible categories.

      Ideally, I prefer to use an authentication system that's similar to the write-api... but if cookies are the only way to authenticate requests, I'm OK with it. I just need to be able to pull user cookies and cache them on my backend and either extend the expiration or push changes to my backend whenever the cookies expire.

      posted in Technical Support
      truetuna
      truetuna
    • RE: Redis server outdated, is actually v3.0.3

      In case anyone else in the future is reading this, I had the exact same problem when I was deploying NodeBB to AWS using the Ubuntu 14.04 LTS AMI.

      I had installed the latest version Redis by compiling from source (see tutorial here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis) but I had forgotten to uninstall the default redis-server package that came along with Ubuntu. After uninstalling the default redis-server package, the error message went away.

      sudo apt-get --purge autoremove redis-server
      
      posted in Technical Support
      truetuna
      truetuna
    • RE: How can I read a resource only by their id (cid, uid, tid etc.) rather than the name or name+id?

      Hey @baris, I made a PR yesterday.

      posted in NodeBB Development
      truetuna
      truetuna