How to have forum use a custom email plugin over default ones in list?

Plugin Development
  • Hello,
    I have begun work on a custom email plugin, and while looking at some others that are available to see how they went about things I noticed that all of the available plugins (at least that I have found so far) already have an entry in the email setup list, regardless of if you have downloaded the associated plugin for that service (ex. Sendgrid, Mailgun, etc).

    So my questions is, if I have a custom email plugin, how exactly would I go about making it selectable / usable by the forum? Does it need to be present in the default email list? Is there a way to have my plugin inject itself into that list of providers or is there a way to override that list so that the forum knows not to use the credentials and settings in there, but instead use the ones in the plugin?

    The only real switch I have found is the "Use an external email server to send emails", which I would imagine that if it is turned off, that would not be much help either.

    If anyone has any insight on how the system works in regards to this and can point me in the right direction, I would appreciate it!

    Thanks,
    -MH


Suggested Topics


  • 2 Votes
    1 Posts
    334 Views

    Whats the right way to use third party libraries?

    I tried to do it descriped in the docs:
    https://docs.nodebb.org/development/plugins/libraries/

    But it doenst work.

    I want to use Swiper in my Theme:
    https://swiperjs.com/get-started/

    I tried it with

    "modules": { "swiper.js": "node_modules/swiper/swiper-bundle.min.js" }

    in client.js i used:

    require(['swiper'], function (Swiper) { var mySwiper = new Swiper('.swiper-container', { // Optional parameters direction: 'vertical', loop: true, // If we need pagination pagination: { el: '.swiper-pagination', }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, // And if we need scrollbar scrollbar: { el: '.swiper-scrollbar', }, }) });

    The Javascript from Swiper does not load.

    Can you help me?

    I also treid to import it directly via html

    <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"> <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>

    and I also copied the contents of:
    https://unpkg.com/[email protected]/swiper-bundle.js

    and createt a file unter /lib/swiper-bundle.min.js. Nothing worked for me. The JS is still not loading...

    Looking forward to your answers! 🙂

    I fixed it.

    I am sorry. In my development I use grunt. But it seems that I doesnt load new libraries if installen. So I determinated the process Ctrl+C and restarted it using grunt. The librariers are loaded and the third party library works well now using:

    "modules": { "swiper.js": "node_modules/swiper/swiper-bundle.min.js" } require(['swiper'], function (Swiper) { var mySwiper = new Swiper('.swiper-container', { ... ... ... }) }
  • Creating custom privilege

    Plugin Development
    3
    0 Votes
    3 Posts
    992 Views

    @pitaj Thank you for the detailed answer, appreciate it!

  • 0 Votes
    4 Posts
    1k Views

    @pichalite @PitaJ

    Thanks guys, that worked.

  • 0 Votes
    6 Posts
    2k Views

    @Filozofer while the issue in discussion by @bentael and @baris is good, keep in mind it is still in development and can change at a moments notice!

  • 0 Votes
    4 Posts
    2k Views

    @snodejoke

    Hey, yeah. I've been meaning to reply as well. What I typed above was actually and older 0.6.0 way of searching, and it doesn't actually work the way you want anyway.

    From what I can see, there is no way to search for custom fields using users.js

    It seems the proper way of doing would be to add a sorted set value when you create the field. If the field is a number, something like db.sortedSetAdd('users:yourfield', yourfield, uid, callback) then lookup with db.getSortedSetRangeByScore('users:yourfield', 0, count, min, max, callback), that's how I do it in my plugins now.

    If it's not a number, you need to store it as db.sortedSetAdd('yourfield:sorted', yourfield + ':' + uid, callback) then lookup with db.getSortedSetRangeByLex('yourfield:sorted', min, max, 0, count, callback)

    Here's how I sorted a custom field on my forum without creating a sortedset if you're interested:

    // Get all uids db.getSortedSetRange('users:joindate', 0, -1, function (err, uids) { // Get their custom_field User.getMultipleUserFields(uids, ['uid', custom_field], function (err, users) { // Sort by custom_field async.sortBy(users, function (user, next) { return next(null, user.custom_field); }, function (err, results) { console.log(results); }); }); });

    If not all users have the field, you can use the 'filter:users.get' hook to filter user results to only users that have the field, like I had to do.

    Hooks.filterUsersGet = function (users, next) { // If 'custom_field' isn't in the results, don't filter. if (users && users[0] && users[0].custom_field !== void 0) { // Filter it out if it's null. async.filter(users, function (user, next) { return next(user.custom_field !== null); }, function (results) { next(null, results); }); }else{ next(null, users); } };

    Result:

    [ { uid: '18', uuid: '069a79f444e94726a5befca90e38aaf5' }, { uid: '4', uuid: '294ecf637f1242c6a95d9cf8cc6da3ef' }, { uid: '3', uuid: '32a46cc646d64ffea4da962692858288' }, { uid: '5', uuid: '621ad5087ed448dd92dbc83950a222d9' }, { uid: '17', uuid: 'a85e5f36dc5e465d9c86c6ad88912e99' }, { uid: '1', uuid: 'f19cb1605bc24838835a07757d60ce80' } ]