mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-26 16:30:36 +02:00
made lookup bug free
so that full names can get the right channel. And case is not considered when looking up channels.
This commit is contained in:
parent
39db07085f
commit
9014304320
@ -3,7 +3,7 @@ import 'package:logging/logging.dart';
|
|||||||
|
|
||||||
// name of executable
|
// name of executable
|
||||||
const String exename = "nostr_console";
|
const String exename = "nostr_console";
|
||||||
const String version = "0.2.4-beta";
|
const String version = "0.2.5-beta";
|
||||||
|
|
||||||
int gDebug = 0;
|
int gDebug = 0;
|
||||||
int gSpecificDebug = 0;
|
int gSpecificDebug = 0;
|
||||||
|
@ -169,7 +169,7 @@ int getLatestMessageTime(ScrollableMessages channel) {
|
|||||||
|
|
||||||
Channel? getChannel(List<Channel> channels, String channelId) {
|
Channel? getChannel(List<Channel> channels, String channelId) {
|
||||||
for( int i = 0; i < channels.length; i++) {
|
for( int i = 0; i < channels.length; i++) {
|
||||||
if( channels[i].channelId == channelId) {
|
if( channels[i].channelId.toLowerCase() == channelId.toLowerCase()) {
|
||||||
return channels[i];
|
return channels[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1581,7 +1581,7 @@ class Store {
|
|||||||
|
|
||||||
Channel? getChannelFromId(List<Channel> chs, String channelId) {
|
Channel? getChannelFromId(List<Channel> chs, String channelId) {
|
||||||
for( int i = 0; i < chs.length; i++) {
|
for( int i = 0; i < chs.length; i++) {
|
||||||
if( chs[i].channelId == channelId) {
|
if( chs[i].channelId.toLowerCase() == channelId.toLowerCase()) {
|
||||||
return chs[i];
|
return chs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1717,30 +1717,39 @@ class Store {
|
|||||||
Set<String> fullChannelId = {};
|
Set<String> fullChannelId = {};
|
||||||
for(int i = 0; i < listChannels.length; i++) {
|
for(int i = 0; i < listChannels.length; i++) {
|
||||||
if( listChannels[i].channelId.length >= channelId.length && listChannels[i].channelId.substring(0, channelId.length) == channelId ) {
|
if( listChannels[i].channelId.length >= channelId.length && listChannels[i].channelId.substring(0, channelId.length) == channelId ) {
|
||||||
fullChannelId.add(listChannels[i].channelId);
|
fullChannelId.add(listChannels[i].channelId.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup in channel room name
|
// lookup in channel room name
|
||||||
for(int i = 0; i < listChannels.length; i++) {
|
for(int i = 0; i < listChannels.length; i++) {
|
||||||
Channel room = listChannels[i];
|
Channel room = listChannels[i];
|
||||||
if( room.chatRoomName.length < channelId.length) {
|
if( room.chatRoomName.length < channelId.length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//print("comparing with name ${room.chatRoomName}");
|
|
||||||
if( room.chatRoomName.substring(0, channelId.length) == channelId ) {
|
if( room.chatRoomName.substring(0, channelId.length).toLowerCase() == channelId.toLowerCase() ) {
|
||||||
fullChannelId.add(room.channelId);
|
|
||||||
|
if( room.chatRoomName.toLowerCase() == channelId.toLowerCase()) {
|
||||||
|
//if there is an exact match in name, then use that
|
||||||
|
fullChannelId = {};
|
||||||
|
fullChannelId.add(room.channelId.toLowerCase());
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// otherwise add it to list
|
||||||
|
fullChannelId.add(room.channelId.toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if( fullChannelId.length == 1) {
|
if( fullChannelId.length == 1) {
|
||||||
Channel? room = getChannel( listChannels, fullChannelId.first);
|
Channel? room = getChannel( listChannels, fullChannelId.first);
|
||||||
if( room != null) {
|
if( room != null) {
|
||||||
|
|
||||||
if( room.participants.length > 0) {
|
if( room.roomType == enumRoomType.kind140) {
|
||||||
// enforce the participants-only rule
|
// enforce the participants-only rule
|
||||||
if( !room.participants.contains(userPublicKey)) {
|
if( !room.participants.contains(userPublicKey)) {
|
||||||
print("\nnot a user: ${room.participants}");
|
print("\nYou are not not a participant in this encrypted room, where the participant list is: ${room.participants}");
|
||||||
print("room name: ${room.chatRoomName}");
|
print("room name: ${room.chatRoomName}");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ Set<String>? getTagsFromContent(String content) {
|
|||||||
if( tags == null)
|
if( tags == null)
|
||||||
tags = {};
|
tags = {};
|
||||||
|
|
||||||
tags.add( content.substring(match.start + 1, match.end) );
|
tags.add( content.substring(match.start + 1, match.end).trim() );
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: nostr_console
|
name: nostr_console
|
||||||
description: A multi-platform nostr client built for terminal/console
|
description: A multi-platform nostr client built for terminal/console
|
||||||
version: 0.2.4-beta
|
version: 0.2.5-beta
|
||||||
homepage: https://github.com/vishalxl/nostr_console
|
homepage: https://github.com/vishalxl/nostr_console
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,6 +292,7 @@ String expectedResult =
|
|||||||
Set<String>? tags = getTagsFromContent(content1);
|
Set<String>? tags = getTagsFromContent(content1);
|
||||||
//print(tags);
|
//print(tags);
|
||||||
expect(tags?.length, 6);
|
expect(tags?.length, 6);
|
||||||
|
expect(tags?.contains("bitcoin"), true);
|
||||||
});
|
});
|
||||||
return ;
|
return ;
|
||||||
} // end main
|
} // end main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user