Skip to content

Commit

Permalink
Add Message for Delete Member Event (#530)
Browse files Browse the repository at this point in the history
Co-authored-by: kohlros <[email protected]>

Co-authored-by: kohlros <[email protected]>
  • Loading branch information
LucasDerReisende and kohlros authored Jul 24, 2022
1 parent b48d4fb commit 1bc0a75
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ accessing
asText

| names |

names := self members collect: [:aUserId | (self core userStore getUserFor: aUserId) fullName].
^ 'Added: ' , (names joinSeparatedBy: ', ')
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"class" : {
"newFrom:" : "rgw 7/21/2022 13:36" },
"newFrom:" : "LR 7/23/2022 10:06" },
"instance" : {
"asSnippet" : "rgw 7/21/2022 14:15",
"asText" : "rgw 7/21/2022 15:06",
"asText" : "LR 7/23/2022 10:59",
"members" : "rgw 7/21/2022 13:33",
"members:" : "rgw 7/21/2022 13:33" } }
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"isPrivate" : "per 6/4/2021 14:42",
"isSuperGroup" : "per 6/15/2021 08:09",
"lastMessage" : "aka 7/14/2022 14:28",
"lastMessageDate" : " 7/22/2022 10:40:18",
"lastMessageDate" : "7/22/2022 10:40:18",
"lastMessageId" : "JB 8/4/2021 00:10",
"lastMessageSenderId" : "LR 7/14/2022 12:16",
"lastMessageSenderId:" : "LR 7/14/2022 15:11",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reprents a message where a member is removed from a group.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
instance creation
newFrom: aJsonObject

^ self new
member: (aJsonObject at: 'user_id');
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
asSnippet

^ self asText
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
asText

| name |
name := (self core userStore getUserFor: self member) fullName.
^ 'Removed: ' , name
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
member: aUserId

member := aUserId
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
member

^ member
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"class" : {
"newFrom:" : "LR 7/23/2022 10:41" },
"instance" : {
"asSnippet" : "LR 7/23/2022 10:43",
"asText" : "LR 7/23/2022 10:45",
"member" : "LR 7/23/2022 10:56",
"member:" : "LR 7/23/2022 10:57" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "LR 7/23/2022 10:54",
"instvars" : [
"member" ],
"name" : "TCCDeleteMemberMessage",
"pools" : [
],
"super" : "TCCUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ newMessageWith: aJsonObject
['messageText'] -> [TCCTextMessage newFrom: aJsonObject].
['messagePhoto'] -> [TCCPhotoMessage newFrom: aJsonObject].
['messageChatAddMembers'] -> [TCCAddMembersMessage newFrom: aJsonObject].
['messageChatDeleteMember'] -> [TCCDeleteMemberMessage newFrom: aJsonObject].
} otherwise: [TCCNotSupportedMessage new]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newMessageWith:" : "rgw 7/21/2022 13:43" },
"newMessageWith:" : "LR 7/23/2022 10:44" },
"instance" : {
"chat" : "aka 7/14/2022 16:41",
"chat:" : "aka 7/14/2022 16:41",
Expand All @@ -11,8 +11,8 @@
"date:" : "aka 7/14/2022 16:40",
"id" : "aka 7/14/2022 16:40",
"id:" : "aka 7/14/2022 16:40",
"initialize" : " 7/22/2022 10:40:18",
"isFirstMessageOfDay" : " 7/22/2022 10:40:18",
"isFirstMessageOfDay:" : " 7/22/2022 10:40:18",
"isLastMessageOfDay" : " 7/22/2022 10:40:18",
"isLastMessageOfDay:" : " 7/22/2022 10:40:18" } }
"initialize" : "7/22/2022 10:40:18",
"isFirstMessageOfDay" : "7/22/2022 10:40:18",
"isFirstMessageOfDay:" : "7/22/2022 10:40:18",
"isLastMessageOfDay" : "7/22/2022 10:40:18",
"isLastMessageOfDay:" : "7/22/2022 10:40:18" } }
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"instance" : {
"addAtBottom:" : "rgw 7/21/2022 15:02",
"addAtTop:" : "rgw 7/21/2022 15:02",
"addBottomDayDividerForDate:" : " 7/22/2022 15:41:43",
"addBottomDayDividerForDate:" : "7/22/2022 15:41:43",
"addMessages" : "RS 7/17/2021 17:40",
"addTopDayDividerForDate:" : "js 7/18/2022 07:30",
"chat" : "js 7/31/2020 16:39",
"chat:" : "js 7/31/2020 16:39",
"core" : "JB 6/26/2021 10:22",
"createDayDividerForDate:" : " 7/22/2022 15:41:43",
"createDayDividerForDate:" : "7/22/2022 15:41:43",
"createMessageItemFrom:" : "rgw 7/21/2022 15:09",
"displayChat:" : "RS 7/17/2021 11:54",
"initialize" : "RS 7/17/2021 17:40",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ newFrom: aCoreMessage
[TCCTextMessage] -> [TCUTextMessage].
[TCCPhotoMessage] -> [TCUPhotoMessage].
[TCCAddMembersMessage] -> [TCUInfoMessage].
[TCCDeleteMemberMessage] -> [TCUInfoMessage].
} otherwise: [TCUTextMessage])
basicNew
messageModel: aCoreMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"defaultBottomMargin" : "aka 7/14/2022 16:20",
"defaultMargins" : "aka 7/14/2022 16:20",
"newFrom:" : "rgw 7/22/2022 15:13" },
"newFrom:" : "LR 7/23/2022 10:44" },
"instance" : {
"isUserMessage" : "rgw 7/21/2022 14:07",
"messageModel" : "aka 7/14/2022 17:22",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testMessageDeleteMemberCorrectlyConstructedFromJson

| chat deleteMemberEvent deleteMemberMessage |

chat := TCTMMocks mockBasicGroupChat.
deleteMemberEvent := TCTMMocks mockMessageDeleteMemberWith: TCTMMocks mockUser1 id from: chat id.
deleteMemberMessage := TCCUserMessage newFromMessageEvent: deleteMemberEvent in: chat with: self core.

self assert: deleteMemberMessage member equals: (TCTMMocks mockUser1 id).
self assert: 'Removed: Test User' equals: deleteMemberMessage asSnippet.
self assert: 'Removed: Test User' equals: deleteMemberMessage asText
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"instance" : {
"testMessageAddMembersCorrectlyConstructedFromJson" : "rgw 7/21/2022 16:04",
"testMessageCorrectlyConstructedFromJson" : "aka 7/14/2022 16:58",
"testMessageDeleteMemberCorrectlyConstructedFromJson" : "LR 7/23/2022 11:01",
"testMessageHasTextRepresentation" : "tom.richter 6/26/2021 21:06",
"testMessageIsReply" : "rgw 5/12/2022 16:40",
"testMessageReplySnippetTruncates" : "aka 7/14/2022 16:56",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
message - json
mockMessageDeleteMemberWith: aUserId from: aChatId

^ (JsonObject newFrom: {
'@type' -> 'message'.
'id' -> self mockMessageId.
'chat_id' -> aChatId.
'sender_id' -> (JsonObject newFrom: {
'@type' -> #messageSenderChat.
'user_id' -> self mockUser1 id
}).
'content' -> (JsonObject newFrom: {
'@type'->'messageChatDeleteMember'.
'user_id'-> aUserId
}).
'is_outgoing' -> false.
'reply_to_message_id' -> 0.
'date' -> self mockMessageTimestamp
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"mockMembers" : "rgw 6/2/2022 10:04",
"mockMessageAddMembersFrom:to:" : "rgw 7/21/2022 15:05",
"mockMessageDate" : "TR 6/25/2021 21:07",
"mockMessageDeleteMemberWith:from:" : "LR 7/23/2022 10:13",
"mockMessageEventFrom:" : "pk 8/5/2021 17:09",
"mockMessageFrom:with:" : "aka 7/14/2022 16:57",
"mockMessageId" : "8/5/2021 21:14:18",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
testDeleteMemberMessage

| deleteMemberEvent deleteMemberMessage chat |

chat := TCTMMocks mockBasicGroupChat.
deleteMemberEvent := TCTMMocks mockMessageDeleteMemberWith: TCTMMocks mockUser1 id from: chat id.
deleteMemberMessage := TCCUserMessage newFromMessageEvent: deleteMemberEvent in: chat with: self core.

self wantsToTest: (TCUMessage newFrom: deleteMemberMessage).
self assertReading: 'Removed: Test User' in: self subject
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
testDeleteMemberMessageIsNotUserMessage

| deleteMemberEvent deleteMemberMessage chat |

chat := TCTMMocks mockBasicGroupChat.
deleteMemberEvent := TCTMMocks mockMessageDeleteMemberWith: TCTMMocks mockUser1 id from: chat id.
deleteMemberMessage := TCCUserMessage newFromMessageEvent: deleteMemberEvent in: chat with: self core.

self wantsToTest: (TCUMessage newFrom: deleteMemberMessage).
self deny: self subject isUserMessage
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"setUp" : "rgw 6/6/2022 18:42",
"testAddMembersMessage" : "rgw 7/21/2022 16:02",
"testAddMembersMessageIsNotUserMessage" : "rgw 7/21/2022 16:01",
"testDeleteMemberMessage" : "LR 7/23/2022 11:01",
"testDeleteMemberMessageIsNotUserMessage" : "LR 7/23/2022 11:02",
"testMessageBetweenRequestsAnsweredMessage" : "LR 5/29/2022 17:34",
"testMessageColorsDifferentForIncomingOutgoing" : "tom.richter 6/26/2021 17:23",
"testMessageContainsDate" : "tom.richter 6/26/2021 17:23",
Expand Down

0 comments on commit 1bc0a75

Please sign in to comment.