]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user.ts
Users can change ownership of their video [#510] (#888)
[github/Chocobozzz/PeerTube.git] / server / models / account / user.ts
index 89265774b6686674c5a98bcc685903927c1dcc67..4b13e47a0dc306d76a62acc3a61da8979e2cb2ee 100644 (file)
@@ -39,6 +39,7 @@ import { AccountModel } from './account'
 import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
 import { values } from 'lodash'
 import { NSFW_POLICY_TYPES } from '../../initializers'
+import { VideoFileModel } from '../video/video-file'
 
 enum ScopeNames {
   WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@@ -393,4 +394,15 @@ export class UserModel extends Model<UserModel> {
                       return parseInt(total, 10)
                     })
   }
+
+  static autocomplete (search: string) {
+    return UserModel.findAll({
+      where: {
+        username: {
+          [Sequelize.Op.like]: `%${search}%`
+        }
+      }
+    })
+      .then(u => u.map(u => u.username))
+  }
 }