Tustin / psn-php

A PHP wrapper for the PSN API
https://tustin.dev/psn-php/
MIT License
356 stars 73 forks source link

[V3] Message Types #187

Closed Bornhall closed 2 years ago

Bornhall commented 3 years ago

I'm not familiar enough with GitHub to do pull requests or whatever is needed to contribute to the code base, but here are a few tidbits of my findings of 3.0.0 so far. Possibly you have fixed this already, but anyways.

In: Enum\MessageType.php

Add:

    private const addedUserToGroup = 2001;
    private const startedVoiceChatWithUsers = 2006;

In: Model\Message\ImageMessage.php

Add:

use Tustin\PlayStation\Enum\MessageType;

...and...

    public function type(): MessageType
    {
        return MessageType::image();
    }
Bornhall commented 3 years ago

Looking further at the output from old messages (they threw errors, which is why I investigated), I need to go back on the naming of one of the above consts.

The addedUserToGroup may be fine as is, but startedVoiceChatWithUsers needs to be changed to something like startedNewGroup or similar. Looking back it seems to me that it's unrelated to voice chat altogether, it's just the message type given when a user starts a new message group/thread (what IS the distinction between Group and Thread?) with another user.

In addition, would it be more prudent to allow unknown message types to "pass through" instead of throwing exceptions from Enum? Before adding the above code to MessageType.php I would get errors like this:

PHP Fatal error:  Uncaught UnexpectedValueException: Value '2006' is not part of the enum Tustin\PlayStation\Enum\MessageType in /Volumes/Dev/PSNTest/vendor/myclabs/php-enum/src/Enum.php:245
Bornhall commented 2 years ago

Hey again, while browsing through the code mentioned in another issue, I found the following which might be of help determining what the message types are:

e.MessageType = c, (function(t) {
    t[t.Unexpected = -100] = "Unexpected",
    t[t.Rating = -200] = "Rating",
    t[t.Text = 1] = "Text",
    t[t.TextWithImage = 3] = "TextWithImage",
    t[t.TextWithStoreLink = 8] = "TextWithStoreLink",
    t[t.GameInvitation = 200] = "GameInvitation",
    t[t.Video = 210] = "Video",
    t[t.Voice = 1011] = "Voice",
    t[t.ICal = 1012] = "ICal",
    t[t.Sticker = 1013] = "Sticker",
    t[t.InGameEvent = 1100] = "InGameEvent",
    t[t.OfficialBroadcastEvent = 1101] = "OfficialBroadcastEvent",
    t[t.SharedFactoryEvent = 1102] = "SharedFactoryEvent",
    t[t.UserScheduledEvent = 1103] = "UserScheduledEvent",
    t[t.TournamentEvent = 1104] = "TournamentEvent",
    t[t.Party = 1200] = "Party",
    t[t.ShareMusicPlaylist = 1300] = "ShareMusicPlaylist",
    t[t.ShareMusicAlbum = 1301] = "ShareMusicAlbum",
    t[t.ShareMusicArtist = 1302] = "ShareMusicArtist",
    t[t.ShareMusicTrack = 1303] = "ShareMusicTrack",
    t[t.EventAddMember = 2001] = "EventAddMember",
    t[t.EventWithdrawal = 2002] = "EventWithdrawal",
    t[t.EventEditMessageGroupName = 2003] = "EventEditMessageGroupName",
    t[t.EventAddMessageGroupThumbnail = 2004] = "EventAddMessageGroupThumbnail",
    t[t.EventDeleteMessageGroupThumbnail = 2005] = "EventDeleteMessageGroupThumbnail",
    t[t.EventAddNewMessageGroup = 2006] = "EventAddNewMessageGroup",
    t[t.DeleteTextWithImage = 2007] = "DeleteTextWithImage",
    t[t.DeleteVideo = 2008] = "DeleteVideo",
    t[t.EventKickout = 2011] = "EventKickout",
    t[t.EventTakedown = 2100] = "EventTakedown",
    t[t.EventRemovedEventByAccountClosure = 2200] = "EventRemovedEventByAccountClosure",
    t[t.EventWithdrawalByAccountClosure = 2202] = "EventWithdrawalByAccountClosure"
})(c || (e.MessageType = c = {}));
Tustin commented 2 years ago

@Bornhall Thanks a lot! For some reason I never bothered decompiling the app to find all the types. I'll get these added soon.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.