Shun Miyazawa пре 4 година
родитељ
комит
85da72f41a
2 измењених фајлова са 4 додато и 4 уклоњено
  1. 3 3
      src/server/models/user.js
  2. 1 1
      src/server/routes/apiv3/users.js

+ 3 - 3
src/server/models/user.js

@@ -63,7 +63,7 @@ module.exports = function(crowi) {
     createdAt: { type: Date, default: Date.now },
     lastLoginAt: { type: Date },
     admin: { type: Boolean, default: 0, index: true },
-    invitationEmailSended: { type: Date, default: null },
+    isInvitationEmailSended: { type: Boolean, default: false },
   }, {
     toObject: {
       transform: (doc, ret, opt) => {
@@ -683,14 +683,14 @@ module.exports = function(crowi) {
     return username;
   };
 
-  userSchema.statics.updateInvitationEmailSended = async function(id) {
+  userSchema.statics.updateIsInvitationEmailSended = async function(id) {
     const user = await this.findById(id);
 
     if (!user) {
       throw new Error('User not found');
     }
 
-    user.invitationEmailSended = new Date();
+    user.isInvitationEmailSended = true;
     user.save();
   };
 

+ 1 - 1
src/server/routes/apiv3/users.js

@@ -126,7 +126,7 @@ module.exports = (crowi) => {
     for (const user of userList) {
       try {
         // eslint-disable-next-line no-await-in-loop
-        await User.updateInvitationEmailSended(user.user.id);
+        await User.updateIsInvitationEmailSended(user.user.id);
         // eslint-disable-next-line no-await-in-loop
         await mailService.send({
           to: user.email,