Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mention for read node #22

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ n8n コミュニティ ノードのドキュメントの [インストール ガ
- 生のJsonイベント(advanced)
- [Nostr Read](./doc/read-ja.md)
- イベントの取得
- イベントID・公開鍵・文字列検索(NIP-50)・ハッシュタグによるクエリ
- イベントID・公開鍵・文字列検索(NIP-50)・ハッシュタグ・メンション・jsonのフィルタによるクエリ

## Credentials

Expand Down Expand Up @@ -78,7 +78,6 @@ yarn lint

## TODO

- メンションによるイベントのクエリ
- リレーからイベントを取得してトリガーする新たなノード

## See also
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes
- Raw Json Event(advanced)
- [Nostr Read](./doc/read.md)
- Fetch kind1 events
- Query by eventId, public key, search word(NIP-50) and hashtag.
- Query by eventId, public key, search word(NIP-50), hashtag, mention, and json filter.

## Credentials

Expand Down Expand Up @@ -77,7 +77,6 @@ yarn lint

## TODO

- Query events by mention.
- Trigger node by getting event from relay.

## See also
Expand Down
30 changes: 30 additions & 0 deletions nodes/NostrobotsRead/Nostrobotsread.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class Nostrobotsread implements INodeType {
name: 'Hashtag',
value: 'hashtag',
},
{
name: 'Mention',
value: 'mention',
},
{
name: 'RawFilter(advanced)',
value: 'rawFilter',
Expand Down Expand Up @@ -135,6 +139,20 @@ export class Nostrobotsread implements INodeType {
description: 'Raw filter JSON. But since and until value are overwrited with form value.',
hint: 'NIP-01. https://github.com/nostr-protocol/nips/blob/master/01.md#communication-between-clients-and-relays',
},
{
displayName: 'Mention',
name: 'mention',
type: 'string',
required: true,
displayOptions: {
show: {
strategy: ['mention'],
},
},
default: '',
placeholder: 'npub...',
description: 'Mention search. Please enter the public key of the person mentioned.',
},
// common option
{
displayName: 'Relative',
Expand Down Expand Up @@ -342,6 +360,18 @@ export class Nostrobotsread implements INodeType {

break;

case 'mention':
const mentionedpubkey = getHexPubKey(this.getNodeParameter('mention', i) as string);

filter = {
kinds: [1],
'#p': [mentionedpubkey],
since,
until,
};

break;

default:
throw new NodeOperationError(
this.getNode(),
Expand Down
Loading