<commit_before>'use strict';

const path = require('path');

function getApp(model) {
  return new Promise((resolve, reject) => {
    model.getApp((err, app) => {
      if (err) return reject(err);
      resolve(app);
    });
  });
}

module.exports = async User => {
  const app = await getApp(User);
  const Group = app.models.Group;

  User.disableRemoteMethodByName('prototype.__findById__groups');
  User.disableRemoteMethodByName('prototype.__get__groups');
  User.disableRemoteMethodByName('prototype.__destroyById__groups');
  User.disableRemoteMethodByName('prototype.__count__groups');
  User.disableRemoteMethodByName('prototype.__updateById__groups');
  User.disableRemoteMethodByName('prototype.__delete__groups');

  User.afterRemote('*.__create__groups', async (context, instance) => {
    await instance.members.add(instance.ownerId);
    await instance.save();
  });

  if (process.env.NODE_ENV !== 'testing') {
    User.afterRemote('create', async (context, user) => {
      const options = {
        type: 'email',
        protocol: process.env.PROTOCOL || 'http',
        port: process.env.DISPLAY_PORT || 3000,
        host: process.env.HOSTNAME || 'localhost',
        to: user.email,
        from: '<EMAIL>',
        user: user,
      };

      user.verify(options, (err, response) => {
        if (err) {<commit_msg>:sparkles: Give the group creator user admin role<commit_after>'use strict';

const path = require('path');

function getApp(model) {
  return new Promise((resolve, reject) => {
    model.getApp((err, app) => {
      if (err) return reject(err);
      resolve(app);
    });
  });
}

module.exports = async User => {
  const app = await getApp(User);
  const Group = app.models.Group;

  User.disableRemoteMethodByName('prototype.__findById__groups');
  User.disableRemoteMethodByName('prototype.__get__groups');
  User.disableRemoteMethodByName('prototype.__destroyById__groups');
  User.disableRemoteMethodByName('prototype.__count__groups');
  User.disableRemoteMethodByName('prototype.__updateById__groups');
  User.disableRemoteMethodByName('prototype.__delete__groups');

  User.afterRemote('*.__create__groups', async (context, instance) => {
    await instance.members.add(instance.ownerId);
    await instance.admins.add(instance.ownerId);
    await instance.save();
  });

  if (process.env.NODE_ENV !== 'testing') {
    User.afterRemote('create', async (context, user) => {
      const options = {
        type: 'email',
        protocol: process.env.PROTOCOL || 'http',
        port: process.env.DISPLAY_PORT || 3000,
        host: process.env.HOSTNAME || 'localhost',
        to: user.email,
        from: '<EMAIL>',
        user: user,
      };

      user.verify(options, (err, response) => {
        if (err) {
{'fraction_non_alphanumeric': 0.14755877034358048, 'fraction_numerical': 0.0028933092224231465, 'mean_word_length': 3.7607573149741826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4904524', 'n_tokens_mistral': 813, 'n_tokens_neox': 815, 'n_words': 155}