DEV: use group_ids instead of group_names in invite params
This commit is contained in:
parent
eb73048b0f
commit
ba57dc57cc
|
@ -41,10 +41,6 @@ export default Component.extend({
|
|||
return false;
|
||||
},
|
||||
|
||||
groupFinder(term) {
|
||||
return Group.findAll({ term, ignore_automatic: true });
|
||||
},
|
||||
|
||||
errorMessage: I18n.t("user.invited.invite_link.error"),
|
||||
|
||||
reset() {
|
||||
|
@ -67,9 +63,7 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
const groupNames = this.allGroups
|
||||
.filter(g => this.groupIds.includes(g.id))
|
||||
.map(g => g.name);
|
||||
const groupIds = this.groupIds;
|
||||
const maxRedemptionAllowed = this.maxRedemptionAllowed;
|
||||
const inviteExpiresAt = this.inviteExpiresAt;
|
||||
const userInvitedController = this.userInvitedShow;
|
||||
|
@ -78,7 +72,7 @@ export default Component.extend({
|
|||
|
||||
return model
|
||||
.generateMultipleUseInviteLink(
|
||||
groupNames,
|
||||
groupIds,
|
||||
maxRedemptionAllowed,
|
||||
inviteExpiresAt
|
||||
)
|
||||
|
|
|
@ -310,9 +310,7 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
const groupNames = this.allGroups
|
||||
.filter(g => this.groupIds.includes(g.id))
|
||||
.map(g => g.name);
|
||||
const groupIds = this.groupIds;
|
||||
const userInvitedController = this.userInvitedShow;
|
||||
|
||||
const model = this.inviteModel;
|
||||
|
@ -347,7 +345,7 @@ export default Component.extend({
|
|||
return this.inviteModel
|
||||
.createInvite(
|
||||
this.emailOrUsername.trim(),
|
||||
groupNames,
|
||||
groupIds,
|
||||
this.customMessage
|
||||
)
|
||||
.then(result => {
|
||||
|
@ -385,7 +383,7 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
const groupNames = this.get("inviteModel.groupNames");
|
||||
const groupIds = this.groupIds;
|
||||
const userInvitedController = this.userInvitedShow;
|
||||
const model = this.inviteModel;
|
||||
model.setProperties({ saving: true, error: false });
|
||||
|
@ -396,7 +394,7 @@ export default Component.extend({
|
|||
}
|
||||
|
||||
return model
|
||||
.generateInviteLink(this.emailOrUsername.trim(), groupNames, topicId)
|
||||
.generateInviteLink(this.emailOrUsername.trim(), groupIds, topicId)
|
||||
.then(result => {
|
||||
model.setProperties({
|
||||
saving: false,
|
||||
|
|
|
@ -493,17 +493,17 @@ const Topic = RestModel.extend({
|
|||
});
|
||||
},
|
||||
|
||||
createInvite(user, group_names, custom_message) {
|
||||
createInvite(user, group_ids, custom_message) {
|
||||
return ajax(`/t/${this.id}/invite`, {
|
||||
type: "POST",
|
||||
data: { user, group_names, custom_message }
|
||||
data: { user, group_ids, custom_message }
|
||||
});
|
||||
},
|
||||
|
||||
generateInviteLink(email, groupNames, topicId) {
|
||||
generateInviteLink(email, group_ids, topic_id) {
|
||||
return ajax("/invites/link", {
|
||||
type: "POST",
|
||||
data: { email, group_names: groupNames, topic_id: topicId }
|
||||
data: { email, group_ids, topic_id }
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -668,28 +668,28 @@ const User = RestModel.extend({
|
|||
);
|
||||
},
|
||||
|
||||
createInvite(email, group_names, custom_message) {
|
||||
createInvite(email, group_ids, custom_message) {
|
||||
return ajax("/invites", {
|
||||
type: "POST",
|
||||
data: { email, group_names, custom_message }
|
||||
data: { email, group_ids, custom_message }
|
||||
});
|
||||
},
|
||||
|
||||
generateInviteLink(email, group_names, topic_id) {
|
||||
generateInviteLink(email, group_ids, topic_id) {
|
||||
return ajax("/invites/link", {
|
||||
type: "POST",
|
||||
data: { email, group_names, topic_id }
|
||||
data: { email, group_ids, topic_id }
|
||||
});
|
||||
},
|
||||
|
||||
generateMultipleUseInviteLink(
|
||||
group_names,
|
||||
group_ids,
|
||||
max_redemptions_allowed,
|
||||
expires_at
|
||||
) {
|
||||
return ajax("/invites/link", {
|
||||
type: "POST",
|
||||
data: { group_names, max_redemptions_allowed, expires_at }
|
||||
data: { group_ids, max_redemptions_allowed, expires_at }
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -537,7 +537,7 @@ class Group < ActiveRecord::Base
|
|||
|
||||
def self.lookup_groups(group_ids: [], group_names: [])
|
||||
if group_ids.present?
|
||||
group_ids = group_ids.split(",")
|
||||
group_ids = group_ids.split(",") if group_ids.is_a?(String)
|
||||
group_ids.map!(&:to_i)
|
||||
groups = Group.where(id: group_ids) if group_ids.present?
|
||||
end
|
||||
|
|
|
@ -107,7 +107,7 @@ describe InvitesController do
|
|||
it "allows admins to invite to groups" do
|
||||
group = Fabricate(:group)
|
||||
sign_in(admin)
|
||||
post "/invites.json", params: { email: email, group_names: group.name }
|
||||
post "/invites.json", params: { email: email, group_ids: [group.id] }
|
||||
expect(response.status).to eq(200)
|
||||
expect(Invite.find_by(email: email).invited_groups.count).to eq(1)
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ describe InvitesController do
|
|||
user.update!(trust_level: TrustLevel[2])
|
||||
group.add_owner(user)
|
||||
|
||||
post "/invites.json", params: { email: email, group_names: group.name }
|
||||
post "/invites.json", params: { email: email, group_ids: [group.id] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(Invite.find_by(email: email).invited_groups.count).to eq(1)
|
||||
|
@ -198,7 +198,7 @@ describe InvitesController do
|
|||
sign_in(admin)
|
||||
|
||||
post "/invites/link.json", params: {
|
||||
email: email, group_names: group.name
|
||||
email: email, group_ids: [group.id]
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
@ -245,7 +245,7 @@ describe InvitesController do
|
|||
|
||||
post "/invites/link.json", params: {
|
||||
max_redemptions_allowed: 5,
|
||||
group_names: group.name
|
||||
group_ids: [group.id]
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
|
Loading…
Reference in New Issue