Skip to content

Commit

Permalink
feat: allow using wildcards in antenna
Browse files Browse the repository at this point in the history
  • Loading branch information
supakaity authored and 丈槍由紀 committed Nov 30, 2023
1 parent 1adbd44 commit acda97c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ antennaKeywordsDescription: "Separate with spaces for an AND condition or with l
notifyAntenna: "Notify about new notes"
withFileAntenna: "Only notes with files"
enableServiceworker: "Enable Push-Notifications for your Browser"
antennaUsersDescription: "List one username per line"
antennaUsersDescription: "List one username per line. Use \"*@instance.com\" to specify all users of an instance"
caseSensitive: "Case sensitive"
withReplies: "Include replies"
connectedTo: "Following account(s) are connected"
Expand Down
2 changes: 1 addition & 1 deletion locales/es-ES.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ antennaKeywordsDescription: "Separar con espacios es una declaración AND, separ
notifyAntenna: "Notificar nueva nota"
withFileAntenna: "Sólo notas con archivos adjuntados"
enableServiceworker: "Activar ServiceWorker"
antennaUsersDescription: "Elegir nombres de usuarios separados por una linea nueva"
antennaUsersDescription: "Elegir nombres de usuarios separados por una linea nueva. Utilice \"*@instance.com\" para especificar todos los usuarios de una instancia."
caseSensitive: "Distinguir mayúsculas de minúsculas"
withReplies: "Incluir respuestas"
connectedTo: "Estas cuentas están conectadas"
Expand Down
8 changes: 6 additions & 2 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ export class AntennaService implements OnApplicationShutdown {
const { username, host } = Acct.parse(x);
return this.utilityService.getFullApAccount(username, host).toLowerCase();
});
if (!accts.includes(this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false;
const matchUser = this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase();
const matchWildcard = this.utilityService.getFullApAccount('*', noteUser.host).toLowerCase();
if (!accts.includes(matchUser) && !accts.includes(matchWildcard)) return false;
} else if (antenna.src === 'users_blacklist') {
const accts = antenna.users.map(x => {
const { username, host } = Acct.parse(x);
return this.utilityService.getFullApAccount(username, host).toLowerCase();
});
if (accts.includes(this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false;
const matchUser = this.utilityService.getFullApAccount(noteUser.username, noteUser.host).toLowerCase();
const matchWildcard = this.utilityService.getFullApAccount('*', noteUser.host).toLowerCase();
if (accts.includes(matchUser) || accts.includes(matchWildcard)) return false;
}

const keywords = antenna.keywords
Expand Down

0 comments on commit acda97c

Please sign in to comment.