mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-12-05 01:10:36 +00:00
Search on account name when searching channels
This commit is contained in:
@@ -8,6 +8,7 @@ runs:
|
||||
- name: Setup system dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install postgresql-client-common redis-tools parallel libimage-exiftool-perl
|
||||
wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz"
|
||||
tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz
|
||||
|
||||
@@ -95,6 +95,19 @@ describe('Test channels search', function () {
|
||||
}
|
||||
})
|
||||
|
||||
it('Should also search by account display name', async function () {
|
||||
{
|
||||
const body = await command.searchChannels({ search: 'roat' })
|
||||
expect(body.total).to.equal(0)
|
||||
expect(body.data).to.have.lengthOf(0)
|
||||
}
|
||||
|
||||
{
|
||||
const body = await command.searchChannels({ search: 'root' })
|
||||
expect(body.data.map(c => c.displayName)).to.have.members([ 'Squall channel', 'Main root channel', 'Zell channel' ])
|
||||
}
|
||||
})
|
||||
|
||||
it('Should filter by host', async function () {
|
||||
{
|
||||
const search = { search: 'channel', host: remoteServer.host }
|
||||
|
||||
@@ -107,6 +107,8 @@ export class VideoChannelListQueryBuilder extends AbstractListQuery {
|
||||
}
|
||||
|
||||
if (this.options.search) {
|
||||
this.buildAccountJoin()
|
||||
|
||||
const escapedSearch = this.sequelize.escape(this.options.search)
|
||||
const escapedLikeSearch = this.sequelize.escape('%' + this.options.search + '%')
|
||||
|
||||
@@ -117,7 +119,8 @@ export class VideoChannelListQueryBuilder extends AbstractListQuery {
|
||||
where.push(
|
||||
`(` +
|
||||
`lower(immutable_unaccent(${escapedSearch})) <% lower(immutable_unaccent("VideoChannelModel"."name")) OR ` +
|
||||
`lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(${escapedLikeSearch}))` +
|
||||
`lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(${escapedLikeSearch})) OR ` +
|
||||
`lower(immutable_unaccent("Account"."name")) LIKE lower(immutable_unaccent(${escapedLikeSearch}))` +
|
||||
`)`
|
||||
)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user