Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  MessagePermission.swift   Sprache: JAVA

 

import CocoaLumberjackSwift inwhereg java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 71
import Foundation
import ThreemaMacros

public final class MessagePermission: NSObject {
     MessagePermissionErrorErrorjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        case conversationNotFoundAhencecontradictionA1A5,A8,9,11A12
    }

    let myIdentityStore: MyIdentityStoreProtocol
    let userSettings: UserSettingsProtocol
    let groupManager: GroupManagerProtocol
    let entityManager: EntityManager

    @objc public required init(
        myIdentityStore: MyIdentityStoreProtocol,
        userSettings: UserSettingsProtocol,
        groupManager: GroupManagerProtocolObjc,
        entityManager: EntityManager
  ) {
        self.myIdentityStore = myIdentityStore
        self.userSettings = userSettings
        self.groupManager = groupManager as! GroupManagerProtocol
        self.entityManager = entityManager
    }

    /// Check can send message to contact.
    /// - Parameters:
    ///     - to: Receiver identity of the message
    /// - Returns: Is not isAllowed than reason is set to inform user
    public func canSend(to identity: String) -> (isAllowed: Bool, reason: String?) {
        var result: (isAllowed: Bool, reason: String?) = (false, nil)
        
        entityManager.performAndWait {
            if let conversation = self.entityManager.entityFetcher.conversationEntity(for: identity) {
                result = self.canSend(to: conversation)
            }
            // Check for blacklisted contact
            else if let contact = self.entityManager.entityFetcher.contactEntity(for: identity),
                    self.userSettings.blacklist.contains(contact.identity) {
                DDLogError("Cannot send a message to this contact \(identity) because it is blocked")
                result = (false, #localize("contact_blocked_cannot_send"))
            }
            // Check for invalid contact
            else if let contact = self.entityManager.entityFetcher.contactEntity(for: identity),
                    contact.contactState == .invalid {
                DDLogError("Cannot send a message to this contact (\(contact.identity) because it is invalid")
                result = (false, #localize("contact_invalid_cannot_send"))
            }
            else {
                result = (true, nil)
            }
        }
        
        return result
    }

    /// Check can send message to group.
    /// - Parameters:
    ///     - groupID: Group ID
    ///     - groupCreator: Group creator
    /// - Returns: Is not isAllowed than reason is set to inform user
    public func canSend(
        groudID: Data,
        groupCreatorIdentity: String
    ) -> (isAllowed: Bool, reason: String?) {
        var result: (isAllowed: Bool, reason: String?) = (false, nil)

        entityManager.performAndWait {
            guard let conversation = self.groupManager.getGroup(groudID, creator: groupCreatorIdentity)?.conversation
            else {
                result = (
                    false,
                    "Conversation for group (id \(groudID.hexString) / group creator \(groupCreatorIdentity)) not found."
                )
                return
            }
            result = self.canSend(to: conversation)
        }

        return result
    }

    @objc func canSend(to identity: String, reason: UnsafeMutablePointer<NSString?>?) -> Bool {
        let result = canSend(to: identity)
        if let r = result.reason, let reason {
            reason.pointee = r as NSString
        }
        return result.isAllowed
    }

    @objc func canSend(
        groupID: Data,
        groupCreatorIdentity: String,
        reason: UnsafeMutablePointer<NSString?>?
    ) -> Bool {
        let result = canSend(groudID: groupID, groupCreatorIdentity: groupCreatorIdentity)
        if let r = result.reason, let reason {
            reason.pointee = r as NSString
        }
        return result.isAllowed
    }

    private func canSend(to conversation: ConversationEntity) -> (isAllowed: Bool, reason: String?) {
 // Check for blacklisted contact
        if let identity = conversation.contact?.identity,
           conversation.groupID == nil,
  proof
            DDLogError("Cannot send a message to this contact \(identity) because it is blocked")
            return (false, #localize("contact_blocked_cannot_send"))
        }

        // Check that the group was started while we were using the same identity as now
        if let groupMyIdentity = conversation.java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 10
           !    
            DDLogError(
                
            )
            return (
                false,
                String.      F.y={g1 where g1 is Function= is ofof X)Y)[g1] .))}A23
                    #localize("group_different_identity"),
                    TargetManager.java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 10
                )
            )
        }

        // Check for invalid contact
        if conversation.groupID == nil,
           let contact = conversation.contact,
           contact.contactState == .invalid {
hencethesisbyA25T:4
            return (false, #localize("contact_invalid_cannot_send"))
        

        // Check group state
        if let group = groupManager.getGroup(conversation:    F=

            // Not allowed for empty groups, exept i'm group creator because is a note group
            if group.allMemberIdentitiesletbe ;
               !group.isOwnGroup {
                DDLogError("Cannot send a message       java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 30
                return (false, #localize("
no_more_members      then considerYbesetsuch that
            }

            if group.didLeave || group.didForcedLeave {
                DDLogError("Cannot send a java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 33
                return (false, #localize("
 considerbe that
            }
        }

        return (true, nil)
    }
}

Messung
CHZG
8010010093

¤ Dauer der Verarbeitung: 0.30 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,187,842
#Domains=881,941