Converse converse.js

Source: headless/plugins/muc/affiliations/api.js

  1. import { setAffiliations } from './utils.js';
  2. export default {
  3. /**
  4. * The "affiliations" namespace groups methods relevant to setting and
  5. * getting MUC affiliations.
  6. *
  7. * @namespace api.rooms.affiliations
  8. * @memberOf api.rooms
  9. */
  10. affiliations: {
  11. /**
  12. * Set the given affliation for the given JIDs in the specified MUCs
  13. *
  14. * @param { String|Array<String> } muc_jids - The JIDs of the MUCs in
  15. * which the affiliation should be set.
  16. * @param { Object[] } users - An array of objects representing users
  17. * for whom the affiliation is to be set.
  18. * @param { String } users[].jid - The JID of the user whose affiliation will change
  19. * @param { ('outcast'|'member'|'admin'|'owner') } users[].affiliation - The new affiliation for this user
  20. * @param { String } [users[].reason] - An optional reason for the affiliation change
  21. * @returns { Promise }
  22. *
  23. * @example
  24. * api.rooms.affiliations.set(
  25. * [
  26. * 'muc1@muc.example.org',
  27. * 'muc2@muc.example.org'
  28. * ], [
  29. * {
  30. * 'jid': 'user@example.org',
  31. * 'affiliation': 'member',
  32. * 'reason': "You're one of us now!"
  33. * }
  34. * ]
  35. * )
  36. */
  37. set (muc_jids, users) {
  38. users = !Array.isArray(users) ? [users] : users;
  39. muc_jids = !Array.isArray(muc_jids) ? [muc_jids] : muc_jids;
  40. return setAffiliations(muc_jids, users);
  41. }
  42. }
  43. }