Skip to content

Commit

Permalink
Allow selecting conversations by service ID
Browse files Browse the repository at this point in the history
Closes #65
  • Loading branch information
Tim van der Molen committed Dec 6, 2024
1 parent 98fd1a3 commit 5591f69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func selectConversations(ctx *signal.Context, selectors []string) ([]signal.Conv

var selConvs []signal.Conversation
for _, s := range selectors {
if len(s) == 0 || (len(s) == 1 && (s[0] == '+' || s[0] == '/' || s[0] == '=')) {
if len(s) == 0 || (len(s) == 1 && strings.IndexByte("+/=:", s[0]) >= 0) {
return nil, errors.New("empty conversation selector")
}
var match func(*signal.Recipient) bool
Expand All @@ -51,6 +51,10 @@ func selectConversations(ctx *signal.Context, selectors []string) ([]signal.Conv
match = func(r *signal.Recipient) bool {
return re.MatchString(r.DisplayName())
}
case ':':
match = func(r *signal.Recipient) bool {
return r.Type == signal.RecipientTypeContact && strings.EqualFold(s[1:], r.Contact.ACI)
}
case '=':
s = s[1:]
fallthrough
Expand Down
16 changes: 12 additions & 4 deletions sigtop.1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd October 3, 2024
.Dd December 6, 2024
.Dt SIGTOP 1
.Os
.Sh NAME
Expand Down Expand Up @@ -263,8 +263,10 @@ Because the Signal Desktop database is opened in read-only mode, statements
attempting to modify the database will fail.
.El
.Sh CONVERSATION SELECTORS
Conversation selectors select conversations by name or phone number.
Conversation selectors select conversations by name, phone number or service
ID.
Names can be matched either literally or against a regular expression.
A service ID is a UUID that uniquely identifies a Signal user.
.Pp
A conversation selector of the form
.Sq Cm = Ns Ar name
Expand All @@ -276,9 +278,10 @@ may be omitted if
.Ar name
does not begin with
.Sq = ,
.Sq /
.Sq / ,
.Sq +
or
.Sq + .
.Sq \&: .
For example, the conversation selectors
.Ql =alice
and
Expand All @@ -297,6 +300,11 @@ selects a conversation by phone number.
For example, the conversation selector
.Ql +123456789
matches the conversation with that phone number.
.Pp
A conversation selector of the form
.Sq Cm \&: Ns Ar uuid
selects the conversation with the Signal user whose service ID is
.Ar uuid .
.Sh TIME INTERVALS
A time is specified as
.So
Expand Down

0 comments on commit 5591f69

Please sign in to comment.