Skip to content

Commit

Permalink
Refactored code 2
Browse files Browse the repository at this point in the history
  • Loading branch information
seif khelifi committed Sep 5, 2024
1 parent ddec452 commit 862544d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Binary file added dump.rdb
Binary file not shown.
16 changes: 9 additions & 7 deletions src/groups/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ module.exports = function (Groups) {
// Check for existing groups
await checkGroupExistence(data.name);

// Create group data
const groupData = createGroupData(data, timestamp, isSystem, isHidden, isPrivate, disableJoinRequests, disableLeave, memberCount);
const a = disableLeave;
const b = memberCount;
const c = disableJoinRequests;
const d = isPrivate;
const e = isHidden;

// Create group data
const groupData = createGroupData(data, timestamp, isSystem, e, d, c, a, b);
// Fire hooks and save group data
await plugins.hooks.fire('filter:group.create', { group: groupData, data });
await saveGroupData(groupData, data.ownerUid, timestamp);
Expand All @@ -50,7 +55,8 @@ module.exports = function (Groups) {
}
}

function createGroupData(data, timestamp, isSystem, isHidden, isPrivate, disableJoinRequests, disableLeave, memberCount) {
function createGroupData(data, timestamp, isSystem, isHidden, isPrivate,
disableJoinRequests, disableLeave, memberCount) {
return {
name: data.name,
slug: slugify(data.name),
Expand Down Expand Up @@ -99,10 +105,6 @@ module.exports = function (Groups) {
Groups.isPrivilegeGroup(data.name);
}

async function privilegeGroupExists(name) {
return Groups.isPrivilegeGroup(name) && await db.isSortedSetMember('groups:createtime', name);
}

Groups.validateGroupName = function (name) {
if (!name) {
throw new Error('[[error:group-name-too-short]]');
Expand Down

0 comments on commit 862544d

Please sign in to comment.