mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-24 23:40:25 +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
|
||||
const String exename = "nostr_console";
|
||||
const String version = "0.2.4-beta";
|
||||
const String version = "0.2.5-beta";
|
||||
|
||||
int gDebug = 0;
|
||||
int gSpecificDebug = 0;
|
||||
|
@ -169,7 +169,7 @@ int getLatestMessageTime(ScrollableMessages channel) {
|
||||
|
||||
Channel? getChannel(List<Channel> channels, String channelId) {
|
||||
for( int i = 0; i < channels.length; i++) {
|
||||
if( channels[i].channelId == channelId) {
|
||||
if( channels[i].channelId.toLowerCase() == channelId.toLowerCase()) {
|
||||
return channels[i];
|
||||
}
|
||||
}
|
||||
@ -1581,7 +1581,7 @@ class Store {
|
||||
|
||||
Channel? getChannelFromId(List<Channel> chs, String channelId) {
|
||||
for( int i = 0; i < chs.length; i++) {
|
||||
if( chs[i].channelId == channelId) {
|
||||
if( chs[i].channelId.toLowerCase() == channelId.toLowerCase()) {
|
||||
return chs[i];
|
||||
}
|
||||
}
|
||||
@ -1717,30 +1717,39 @@ class Store {
|
||||
Set<String> fullChannelId = {};
|
||||
for(int i = 0; i < listChannels.length; i++) {
|
||||
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
|
||||
for(int i = 0; i < listChannels.length; i++) {
|
||||
Channel room = listChannels[i];
|
||||
if( room.chatRoomName.length < channelId.length) {
|
||||
continue;
|
||||
}
|
||||
//print("comparing with name ${room.chatRoomName}");
|
||||
if( room.chatRoomName.substring(0, channelId.length) == channelId ) {
|
||||
fullChannelId.add(room.channelId);
|
||||
Channel room = listChannels[i];
|
||||
if( room.chatRoomName.length < channelId.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( room.chatRoomName.substring(0, channelId.length).toLowerCase() == channelId.toLowerCase() ) {
|
||||
|
||||
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
|
||||
|
||||
if( fullChannelId.length == 1) {
|
||||
Channel? room = getChannel( listChannels, fullChannelId.first);
|
||||
if( room != null) {
|
||||
|
||||
if( room.participants.length > 0) {
|
||||
if( room.roomType == enumRoomType.kind140) {
|
||||
// enforce the participants-only rule
|
||||
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}");
|
||||
return "";
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ Set<String>? getTagsFromContent(String content) {
|
||||
if( tags == null)
|
||||
tags = {};
|
||||
|
||||
tags.add( content.substring(match.start + 1, match.end) );
|
||||
tags.add( content.substring(match.start + 1, match.end).trim() );
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
name: nostr_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
|
||||
|
||||
|
||||
# crated location and t rooms
|
||||
# t tags added for all tags
|
||||
|
||||
|
||||
environment:
|
||||
sdk: '>=2.17.3 <3.0.0'
|
||||
|
||||
|
@ -292,6 +292,7 @@ String expectedResult =
|
||||
Set<String>? tags = getTagsFromContent(content1);
|
||||
//print(tags);
|
||||
expect(tags?.length, 6);
|
||||
expect(tags?.contains("bitcoin"), true);
|
||||
});
|
||||
return ;
|
||||
} // end main
|
||||
|
Loading…
x
Reference in New Issue
Block a user