Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Search on account name when searching channels

Chocobozzz6c47548d511c
diff --git a/.github/actions/reusable-prepare-peertube-run/action.yml b/.github/actions/reusable-prepare-peertube-run/action.yml
index aa5b897c9f..d6f06bc95c 100644
--- a/.github/actions/reusable-prepare-peertube-run/action.yml
+++ b/.github/actions/reusable-prepare-peertube-run/action.yml
@@ -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
diff --git a/packages/tests/src/api/search/search-channels.ts b/packages/tests/src/api/search/search-channels.ts
index 36596e0364..637440e7d6 100644
--- a/packages/tests/src/api/search/search-channels.ts
+++ b/packages/tests/src/api/search/search-channels.ts
@@ -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 }
diff --git a/server/core/models/video/sql/channel/video-channel-list-query-builder.ts b/server/core/models/video/sql/channel/video-channel-list-query-builder.ts
index 51f736e167..e53c8feea7 100644
--- a/server/core/models/video/sql/channel/video-channel-list-query-builder.ts
+++ b/server/core/models/video/sql/channel/video-channel-list-query-builder.ts
@@ -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 {