• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

"messages:uid:fromuid:to:touid" not working as expected?

Scheduled Pinned Locked Moved Bug Reports
messaging.js
3 Posts 2 Posters 1.4k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • agarcia17A Offline
    agarcia17A Offline
    agarcia17
    wrote on last edited by agarcia17
    #1

    Hi, @psychobunny helped me set up my first plugin that will grab/record chat statistics (ex. how many times user1 has messaged user2). I believe NodeBB attempts to record that information here but a bug is keeping it from doing it correctly. I'm guessing it's cause the uids[] array is sorted. So for example, if user1 (uid:1) sends a message to user2 (uid:2), NodeBB correctly saves it into "messages:uid:1:to:2" but now if user2 sends a message to user1, NodeBB again saves it into "messages:uid:1:to:2" even though it's suppose to be "messages:uid:2:to:1". I went ahead and replaced that line with this one "async.apply(db.sortedSetAdd, 'messages:uid:' + fromuid + ':to:' + touid, timestamp, mid)" and it seems like it's working correctly now. Is that the correct/safe way to fix the bug?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #2

    No, when uid 1 and uid 2 are having a conversation all the messages are saved in messages:uid:' + uids[0] + ':to:' + uids[1] the uids array is populated at the top of that function with var uids = sortUids(fromuid, touid); so the lower uid is always the first.

    1 Reply Last reply
    1
  • agarcia17A Offline
    agarcia17A Offline
    agarcia17
    wrote on last edited by
    #3

    ohh ok.. I just thought the other way made more sense since user2 sent the message "to" user1. so saving it as "user2:to:user1" instead of "user1:to:user2" was more intuitive. sorry 🙂

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development