-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
respect muted setting of chats (#397)
* enable muted notifications * building tests * add tests, refactor mocks
- Loading branch information
Showing
24 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCChat.class/instance/muted..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
muted: aBoolean | ||
|
||
muted := aBoolean |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCChat.class/instance/muted.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
muted | ||
|
||
^ muted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/shouldNotify.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
shouldNotify | ||
|
||
^ (self isOutgoing not) and: [self chat muted not] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/TelegramClient-UI.package/TCUMain.class/instance/newMessageReceived..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
event handling | ||
newMessageReceived: aMessage | ||
|
||
aMessage isOutgoing ifFalse: [ | ||
aMessage shouldNotify ifTrue: [ | ||
[(TCUNotification newWithMessage: aMessage) openInWorld] fork]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/TelegramClientTests-Core.package/TCTCMessageTests.class/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this class tests TCCMessages |
7 changes: 7 additions & 0 deletions
7
...ramClientTests-Core.package/TCTCMessageTests.class/instance/testMessageShouldNotNotify.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
testing | ||
testMessageShouldNotNotify | ||
|
||
| chat | | ||
|
||
chat := TCCChat newFromChatEvent: (TCTMMocks mockChatEventMutedFor: 42). | ||
self assert: false equals: ((TCTMMocks mockMessageFor: chat) shouldNotify). |
7 changes: 7 additions & 0 deletions
7
...legramClientTests-Core.package/TCTCMessageTests.class/instance/testMessageShouldNotify.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
testing | ||
testMessageShouldNotify | ||
|
||
| chat | | ||
|
||
chat := TCCChat newFromChatEvent: (TCTMMocks mockChatEventMutedFor: 0). | ||
self assert: true equals: ((TCTMMocks mockMessageFor: chat) shouldNotify). |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClientTests-Core.package/TCTCMessageTests.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"testMessageShouldNotNotify" : "per 6/18/2021 09:28", | ||
"testMessageShouldNotify" : "per 6/18/2021 09:28" } } |
14 changes: 14 additions & 0 deletions
14
packages/TelegramClientTests-Core.package/TCTCMessageTests.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"category" : "TelegramClientTests-Core", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "per 6/16/2021 17:38", | ||
"instvars" : [ | ||
], | ||
"name" : "TCTCMessageTests", | ||
"pools" : [ | ||
], | ||
"super" : "TCTCNoTdlibTestCase", | ||
"type" : "normal" } |
20 changes: 20 additions & 0 deletions
20
packages/TelegramClientTests-Misc.package/TCTMMocks.class/class/mockChatEventMutedFor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
chat event | ||
mockChatEventMutedFor: aNumber | ||
|
||
^ (JsonObject newFrom: { | ||
'@type' -> 'chat'. | ||
'chat' -> (JsonObject newFrom: { | ||
'id' -> self mockBasicGroupChat id. | ||
'title' -> 'MutedMockChat'. | ||
'type' -> (JsonObject newFrom: { | ||
'@type' -> 'chatTypeBasicGroup'. | ||
'basic_group_id' -> self mockBasicGroupChat id. | ||
}). | ||
'permissions' -> (JsonObject newFrom: { | ||
'@type' -> 'can_send_messages' | ||
}). | ||
'notification_settings' -> (JsonObject newFrom: { | ||
'mute_for' -> aNumber | ||
}). | ||
}) | ||
}) |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClientTests-Misc.package/TCTMMocks.class/class/mockMessageFor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
message | ||
mockMessageFor: aChat | ||
|
||
^ TCCMessage newFromMessageEvent: (self mockMessageJsonFrom: aChat id) | ||
in: aChat | ||
with: self mockCore |
5 changes: 5 additions & 0 deletions
5
packages/TelegramClientTests-Misc.package/TCTMMocks.class/class/mockMutedPrivateChat.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
chat | ||
mockMutedPrivateChat | ||
|
||
^ self mockPrivateChat muted: true; | ||
yourself |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...tTests-UI.package/TCTUNotificationTests.class/instance/testMutedNotificationNotVisible.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
testing | ||
testMutedNotificationNotVisible | ||
|
||
| message | | ||
message := TCTMMocks mockMessage. | ||
message chat: TCTMMocks mockMutedPrivateChat. | ||
TCUMain basicNew newMessageReceived: message. | ||
self deny: ((Project current world submorphOfClass: TCUNotification) notNil). |
9 changes: 9 additions & 0 deletions
9
...ntTests-UI.package/TCTUNotificationTests.class/instance/testUnmutedNotificationVisible.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
testing | ||
testUnmutedNotificationVisible | ||
|
||
| message | | ||
message := TCTMMocks mockMessage. | ||
message chat: TCTMMocks mockPrivateChat. | ||
TCUMain basicNew newMessageReceived: message. | ||
1 seconds wait. | ||
self assert: ((Project current world submorphOfClass: TCUNotification) notNil). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters