Skip to content

Commit

Permalink
Merge pull request #36 from beabee-communityrm/feat/callout-channel
Browse files Browse the repository at this point in the history
Feat(callout-channel): Add filter to only list callouts for telegram
  • Loading branch information
JumpLink authored May 10, 2024
2 parents ee9d3a8 + 5d10628 commit 69b70de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions telegram-bot/renderer/callout.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class CalloutRenderer {
* @param listChar
* @returns
*/
public listItem(callout: CalloutDataExt, listChar = "\\-") {
public listItem(callout: GetCalloutDataExt, listChar = "\\-") {
listChar = escapeMd(listChar);

const result: Render = {
Expand Down Expand Up @@ -130,7 +130,7 @@ export class CalloutRenderer {
* @param withUrl Whether to include the URL in the title
* @returns
*/
public title(callout: CalloutDataExt, withUrl = true) {
public title(callout: GetCalloutDataExt, withUrl = true) {
const result: Render = {
key: `callout:title:${callout.shortSlug}`,
type: RenderType.MARKDOWN,
Expand All @@ -156,7 +156,7 @@ export class CalloutRenderer {
* @param callout
* @returns
*/
public async calloutDetails(callout: CalloutDataExt) {
public async calloutDetails(callout: GetCalloutDataExt) {
const imagePath = await downloadImage(callout.image);
const inputFile = new InputFile(await Deno.open(imagePath), callout.title);

Expand Down
5 changes: 3 additions & 2 deletions telegram-bot/services/callout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import type {
Paginated,
} from "../deps/index.ts";

const CALLOUTS_ACTIVE_QUERY: GetCalloutsQuery = {
const CALLOUTS_ACTIVE_TELEGRAM_QUERY: GetCalloutsQuery = {
rules: {
condition: "AND",
rules: [
{ field: "status", operator: "equal", value: [ItemStatus.Open] },
{ field: "expires", operator: "is_empty", value: [] },
{ field: "hidden", operator: "equal", value: [false] },
{ field: "channels", operator: "contains", value: ["telegram"] },
],
},
};
Expand Down Expand Up @@ -122,7 +123,7 @@ export class CalloutService extends BaseService {

public async list(limit = 10) {
const data = await this.client.list({
...CALLOUTS_ACTIVE_QUERY,
...CALLOUTS_ACTIVE_TELEGRAM_QUERY,
limit,
sort: "title",
});
Expand Down

0 comments on commit 69b70de

Please sign in to comment.