Don't show message request after requesting to join via group link

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2024-09-16 16:47:05 -05:00 committed by GitHub
parent ec0d64de6e
commit aa75ec13a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 7 deletions

View file

@ -5146,10 +5146,19 @@ async function applyGroupChange({
} }
// Capture who added us // Capture who added us
if (ourAci && sourceServiceId && addedUuid === ourAci) { if (addedUuid === ourAci && pendingAdminApprovalMembers[ourAci]) {
result.addedBy = ourAci;
} else if (addedUuid === ourAci && sourceServiceId) {
result.addedBy = sourceServiceId; result.addedBy = sourceServiceId;
} }
if (pendingAdminApprovalMembers[addedUuid]) {
log.warn(
`applyGroupChange/${logId}: Removing newly-added member from pendingAdminApprovalMembers.`
);
delete pendingAdminApprovalMembers[addedUuid];
}
if (added.profileKey) { if (added.profileKey) {
newProfileKeys.push({ newProfileKeys.push({
profileKey: added.profileKey, profileKey: added.profileKey,
@ -5291,6 +5300,7 @@ async function applyGroupChange({
log.warn( log.warn(
`applyGroupChange/${logId}: Attempt to promote pendingMember failed; was not in pendingMembers.` `applyGroupChange/${logId}: Attempt to promote pendingMember failed; was not in pendingMembers.`
); );
return;
} }
if (members[aci]) { if (members[aci]) {
@ -5518,6 +5528,7 @@ async function applyGroupChange({
log.warn( log.warn(
`applyGroupChange/${logId}: Attempt to promote pendingAdminApproval failed; was not in pendingAdminApprovalMembers.` `applyGroupChange/${logId}: Attempt to promote pendingAdminApproval failed; was not in pendingAdminApprovalMembers.`
); );
return;
} }
if (pendingMembers[userId]) { if (pendingMembers[userId]) {
delete pendingAdminApprovalMembers[userId]; delete pendingAdminApprovalMembers[userId];
@ -5533,6 +5544,11 @@ async function applyGroupChange({
return; return;
} }
// If we had requested to join, and are approved, we added ourselves
if (userId === ourAci) {
result.addedBy = ourAci;
}
members[userId] = { members[userId] = {
aci: userId, aci: userId,
joinedAtVersion: version, joinedAtVersion: version,
@ -5840,7 +5856,9 @@ async function applyGroupState({
result.left = false; result.left = false;
// Capture who added us if we were previously not in group // Capture who added us if we were previously not in group
if ( if (pendingAdminApprovalMembers[ourAci] && !wasPreviouslyAMember) {
result.addedBy = sourceServiceId;
} else if (
sourceServiceId && sourceServiceId &&
!wasPreviouslyAMember && !wasPreviouslyAMember &&
isNumber(member.joinedAtVersion) && isNumber(member.joinedAtVersion) &&

View file

@ -356,6 +356,7 @@ export async function joinViaLink(value: string): Promise<void> {
tempConversation.set({ tempConversation.set({
// We want to keep this conversation around, since the join succeeded // We want to keep this conversation around, since the join succeeded
isTemporary: undefined, isTemporary: undefined,
profileSharing: true,
}); });
await DataWriter.updateConversation(tempConversation.attributes); await DataWriter.updateConversation(tempConversation.attributes);
} }

View file

@ -62,7 +62,7 @@ export function getRawAvatarPath(
export function getLocalProfileAvatarUrl( export function getLocalProfileAvatarUrl(
conversationAttrs: ConversationAttributesType conversationAttrs: ConversationAttributesType
): string | undefined { ): string | undefined {
const avatar = conversationAttrs.profileAvatar; const avatar = conversationAttrs.profileAvatar || conversationAttrs.avatar;
return avatar?.path ? getLocalAttachmentUrl(avatar) : undefined; return avatar?.path ? getLocalAttachmentUrl(avatar) : undefined;
} }

View file

@ -35,12 +35,26 @@ export function isConversationAccepted(
return true; return true;
} }
const { sentMessageCount } = conversationAttrs; const {
sentMessageCount,
messageCount,
messageCountBeforeMessageRequests,
pendingAdminApprovalV2,
profileSharing,
} = conversationAttrs;
const ourAci = window.storage.user.getAci();
const hasRequestedToJoin =
Boolean(ourAci) &&
(pendingAdminApprovalV2 || []).some(item => item.aci === ourAci);
if (hasRequestedToJoin) {
return true;
}
const hasSentMessages = (sentMessageCount || 0) > 0; const hasSentMessages = (sentMessageCount || 0) > 0;
const hasMessagesBeforeMessageRequests = const hasMessagesBeforeMessageRequests =
(conversationAttrs.messageCountBeforeMessageRequests || 0) > 0; (messageCountBeforeMessageRequests || 0) > 0;
const hasNoMessages = (conversationAttrs.messageCount || 0) === 0; const hasNoMessages = (messageCount || 0) === 0;
// We don't want to show the message request UI in an empty conversation. // We don't want to show the message request UI in an empty conversation.
const isEmptyPrivateConvo = const isEmptyPrivateConvo =
@ -50,7 +64,7 @@ export function isConversationAccepted(
const isEmptyWhitelistedGroup = const isEmptyWhitelistedGroup =
hasNoMessages && hasNoMessages &&
!isDirectConversation(conversationAttrs) && !isDirectConversation(conversationAttrs) &&
Boolean(conversationAttrs.profileSharing); Boolean(profileSharing);
return ( return (
isFromOrAddedByTrustedContact(conversationAttrs) || isFromOrAddedByTrustedContact(conversationAttrs) ||